Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi. I have a website with about 40 pages in it and i want to have a menu on each page, As i frequently add pages I upgrade the menu which is extremely time consuming. Would it be possible to call up the same menu from one file on the server onto each page, so I could update it quickly and efficiently? Can this be done with html alone? I am not keen to change any file extentions for fear of losing page rank.
Many thanks for your help!

It depends on your server environment. But there are a few solutions:
The most flexibe approach (in my opinion) would be to use PHP or ASP. Either of those will do it very easily and allows you to do much, much more. There are ways to utilize it without changing your extensions, but you would need help in either setting up the server to properly process the hmt/html files.
You can use SSI (server side includes) if your server supports it. You would create your menu in html, but name the file with .shtml (the extension of the pages will remain the same so it will not change your ranking). Then in your pages use where you want to display the menu.
The last option (and least advisable) is to use JavaScript. Sort of the same concept as above, but it is done client side as opposed to server side. Create an external JavaScript file with the HTML code inside document.write commands.
document.write("1st line of html");
document.write("2nd line of html");Then in the page to include the menu, use <script language="javascript" source="menu.js"></script>
Michael J

Looks like some of the code was removed. To display the SSI file include this in that page (replace [] with <>):
[!--#include file="menu.shtml" --]
Michael J

That's great, i can see how to include the menu in any page, but what i don't get is how to do it without changing the .html extensions of the existing pages. Surely if i change them to .shtml i will lose the pagerank on them!
Cheers
thomas

Uh, I'm not sure what wasn't clear:
"You would create your menu in html, but name the file with .shtml (the extension of the pages will remain the same so it will not change your ranking)."
You would ONLY make the extension of the menu include file as shtml. All of your current pages would retain their current extensions. You would just add code within those page to include the menu.
Michael J

Sorry for being really dense, but i tried that and it seems that i can only make it work if i give both files .shtml extension. If i leave the original as .html it ignores the SSI that I've placed in the code!
Dunno what i'm doing wrong!
Thanks for getting back to me!
Tom

Never mind, I'm the one that's dense. It's been a long while since I've used those. Yes, the page that calls the include must have the unique extension - this is what tells the server that it need to look for and add any includes in the page.
So, you can use the JavaScript method, but I'd advise against it because it wouldn't work for people that have js disabled.
So, you can do a couple of things:
1. Have your host configure the server to parse htm/html files for includes. I doub't they will do this, but it doesn't hurt to ask.
2. rename all your pages with the shtml extension, then create new pages with the original names, but make them a single frame which loads the new shtml files. This will alllow you to keep your rankings - at least for now. Since the actual page that is loading is just a fram I don't know if the frame source will be indexed.
3. (My preference) rename all of the extensions to shtml. Then recreate the original pages but have them be a page with a meta refresh tag that will load the new shtml page (you should also include some text along the lines of "You will be redirected <u>here</u> after 5 seconds, if not click <u>here</u>"). You will also need to update the links within your code to point tot he shtml pages.
Now, all of your html pages will still be indexed and users will only get the redirect page once when they hit your site from a search engine. Over time the shtml pages will get indexed. You can also put a tag in the header (google for it) of the html redirect pages that will tell the bots not to index them anymore, but make sure they index the linked page! Again, google for more info on how to do this.
Eventually you can check you logs to see how many hits you are getting on you html redirect pages. Once the level is down to an acceptable level you can remove those pages if you wish.
Michael J

Here's a better option. If your ISP supports Mason, you can include external files in the same way as ssi but without having to change the file extentions.
Create a "menu" file that has all of the required html for you menus. Then in your html file add a Mason include statement.
<% menu %>
Mason has more advanced methods for including external files as well as including Perl code directly into the html file much like php but far more powerful.
http://www.masonbook.com/book/

Hi, Thanks for the tip about mason, i am trying to ascertain from my webhost whether they support it or not.
If i understand it correctly, if they support it i need to upload some files to my root directory:
Class::Container 0.07+, File::Spec 0.8+, Params::Validate 0.24+, Exception::Class 1.01+, and Cache::Cache 1.00+.
am i correct so far? then i can add the "menu" file with the <% %> tags. should the menu file be called menu.shtml or just "menu"?Sorry for inane questions, this is a new one on me!
cheers thomas

If your webhost is setup for Mason, they will already have the all of the required modules.
The menu file can be called anything you like, but use the .html extention.

![]() |
Read a file per month
|
Webmessenger ?
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |