Computing.Net > Forums > Web Development > One menu on every page

One menu on every page

Reply to Message Icon

Original Message
Name: chantaspell1977
Date: November 29, 2005 at 06:44:00 Pacific
Subject: One menu on every page
OS: xp sp2
CPU/Ram: 2400ghz 256mb
Comment:

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!


Report Offensive Message For Removal

Response Number 1
Name: Michael J (by mjdamato)
Date: November 29, 2005 at 07:25:41 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 2
Name: Michael J (by mjdamato)
Date: November 29, 2005 at 07:27:43 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 3
Name: chantaspell1977
Date: November 29, 2005 at 08:20:25 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 4
Name: Michael J (by mjdamato)
Date: November 29, 2005 at 09:36:45 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 5
Name: chantaspell1977
Date: November 29, 2005 at 09:58:42 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal


Response Number 6
Name: Michael J (by mjdamato)
Date: November 29, 2005 at 10:57:16 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 7
Name: FishMonger
Date: November 29, 2005 at 16:26:03 Pacific
Subject: One menu on every page
Reply: (edit)

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/


Report Offensive Follow Up For Removal

Response Number 8
Name: chantaspell1977
Date: December 3, 2005 at 05:40:10 Pacific
Subject: One menu on every page
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 9
Name: FishMonger
Date: December 3, 2005 at 07:47:16 Pacific
Subject: One menu on every page
Reply: (edit)

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.


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: One menu on every page

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software