Home > Enterprise >  Possible to create a navbar that updates all pages if the structure changes?
Possible to create a navbar that updates all pages if the structure changes?

Time:12-07

I'm sorry if I'm not articulating this well. I just coded a website for product reviews. I have the navbar code in the header of each page and of course I paste it from page to page.

However, I may have to add articles, or review pages, from time to time, and change the menus, and would like to find a way to change just the navbar code on one page and have the change cascade to all the others, if possible.

For example, right now, if I want to add an article about a certain tool, I have to change the links on the home page and then replace the same code on all the other pages to reflect that change.

Is there any way to get that automatic updating I'm looking for?

Thanks.

CodePudding user response:

It seems to me that you are wanting to use templates. That way you can write the code for the navbar in the template and insert it the template into each page. That way you would only need to change the code on one location and have it apply to every page that you have included the template on.

How to implement templates to do what you are describing will vary depending on the framework that you are using.

Two common frameworks used are Node.js and PHP.

A good answer to how to use templates (called partials) in Node.js can be found here, while a PHP example can be found here.

CodePudding user response:

Maybe some sort of Content Management Systems like WordPress will be a better choice for you. They generate page content according to the rules set. If you want to make and maintain the website yourself, please provide more details about technologies you use.

  • Related