Skip to main content
Known Participant
December 11, 2017
Question

Old Server Side Include method does not show in browser <!--#include file="sidebar1.html" -->

  • December 11, 2017
  • 2 replies
  • 1615 views

I've been updating a small business website for many years. It uses <!--#include file="sidebar1.html" --> to include a side navigation. In Dreamweaver CS3, the navigation would show up on the server but I couldn't see it in Dreamweaver. This was slightly annoying but workable. Now, updating for the first time in Dreamweaver CC, I can see the sidebar navigation in Dreamweaver WYSIWYG but it doesn't actually show up in any browser! How can I get it to work again?

I thought maybe DWCC updated something without asking so I uploaded last year's version of the site from a backup but the nav is still absent. The "sidebar1.html" file is definitely on the server. I read that this include method is very old. Did browsers decide not to support it anymore? The clients here may be shutting down after this year so they don't want to rebuild the site. I've got to fix this somehow.

I'm not good at code, but I found what may be a good replacement, so I tried using the method below, from How To Include HTML . But this also shows up in DWCC but not my browser. Can someone please help me fix or understand this?

<html>

<script src="https://www.w3schools.com/lib/w3.js"></script>

<body>

<div w3-include-html="sidebar1.html"></div>

<script>

w3.includeHTML();

</script>

</body>

</html>

This topic has been closed for replies.

2 replies

Nancy OShea
Community Expert
Community Expert
December 11, 2017

I have never used that method of inserting includes.   I don't know what if any advantage it provides. I use the tried & tested PHP include or virtual include statement.  No JavaScrpts required for any of this..

Inside a PHP file -

          <?php include('folder/sidebar1.html'); ?>       

Or inside a SHTML file.

          <!--#include virtual="folder/sidebar1.html" -->

Upload files to remote server to test.  Or if you wish to test locally, install a local testing server -- Wamp, Xamp or Mamp.

Setting up a PHP environment in Dreamweaver

http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html

Nancy

Nancy O'Shea— Product User & Community Expert
cljffordAuthor
Known Participant
December 13, 2017

Thank you, as well, Nancy.

I tried your method and it didn't work for me either! As I wrote in reply to John Fritz II, I still don't know what caused the original code to break but I wonder if the same thing that kept the original valid code to fail also caused your valid code not to work on my particular server. But then, for some reason, the code in the original post of this thread started working, so I went with that.

Your assistance is appreciated!

Jon Fritz
Community Expert
Community Expert
December 13, 2017

Both SHTML and PHP includes require servers that support them and specific file extensions (in most cases).

If you added a php include to index.html for example, it's very likely it wouldn't work because the server is expecting php includes to be within .php pages. By default most servers won't run php scripts in .html pages.

SHTML includes require .shtml pages in most cases as well, so if you were creating new pages and adding those includes, having a file called about.html wouldn't show the include while about.shtml would.

Jon Fritz
Community Expert
Community Expert
December 11, 2017

If it shows in Live View in DW, but not on your actual server when you open a browser, I would double check your browser cache has been cleared, especially if you like previewing in Chrome.

Chrome changed how their caching works, so it can be a bit of a bear to clear it out completely. Checking from a second computer/browser that hasn't visited the site will do the trick.

The old method is still very much a reliable way to include pages on a site.

cljffordAuthor
Known Participant
December 13, 2017

Thank you for the reply, Jon Fritz II.

I am pretty sure my issue wasn't the browser cache, since I was seeing no navigation in Safari or Chrome or Firefox on multiple computers. It is good to know that the old method is still valid. That was a burning question. I still don't know why it flaked out all of a sudden but I did get it to work using the method in my original post.