Write once to multiple pages

User 368762 Photo

Registered User
122 posts

I have a RSD website with 20+ pages. I am using Menu Builder and have the same menu on each of the 20 pages. If there is an addition or change to the menu I have to copy and paste new info into the header section and html area where the menu appears – on every one of the 20 pages.

Is there some way to have a central location for the HTML code, so if I change the menu in one spot it propagates down to all pages without having to copy and paste the new menu set up on each and every page of the website?
"Live as if you were to die tomorrow. Learn as if you were to live forever" - Gandi

User 78051 Photo

Registered User
201 posts

You just need to use what's called an include.

You need to change your page to either .php or .asp (depending on your server type) rather than .htm/.html and create a new page file in which you place all the code for the menu - for the sake of argument let's say you name that page mainmenu.php

Then on the main pages you replace what you had in place for the menu with the following (in the case of php)

<?php include("mainmenu.php"); ?>

Now, when you update the page mainmenu.php all pages that include it will update from the one page. Here's more info which may help you https://css-tricks.com/snippets/php/php-include/


Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.