Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Robert Norden
Robert Norden
1,594 Points

How to best copy my Navigation Menu to multiple pages

I want to "Copy" my Navigation Bar and Footer to multiple pages. My website will have about 40 pages and I want to be able to make any future changes to my Nav Bar so that it will update all pages at once. It would be ridiculous to have to update every single page. This seems like a very common requirement for all websites using Visual Studio Code. However, doing a google search, I cannot find a concensus on how this is done. I cannot find this solution in any of the Team Treehouse courses I've taken. Can anyone recommend a course or solution? Thank you!

1 Answer

devvoyage
seal-mask
.a{fill-rule:evenodd;}techdegree
devvoyage
Front End Web Development Techdegree Student 14,886 Points

Hi there Robert Norden!

As you continue learning about JavaScript you will find that several things could help you here including a backend language. You might consider learning about React, which is a JavaScript library and fairly extensive at that. This allows you to break your site into "components" such as navigation, footer, etc. Then for each page you want you would include the navigation as a component. So, if you change the navigation component, then that will be echoed across your site for every page that has the navigation component included.

Just a thought! I'd suggest after delving more deeply into JavaScript and getting a good handle on that, you look at the possibilities of React.

Hope this helps! :sparkles:

edited for additional information

The reason you can't find a consensus about this is that there are multiple ways to do it :smile: Based on the site you're describing, you will likely be dealing with a backend language at some point whether it be JavaScript, PHP, Python, C# or any other. I want to take a moment and applaud your forward-thinking mindset because you've already thought about the impracticalities of manually adjusting HTML over a large site . If you continue down the path you're on, those topics will be tackled! Keep it up!

Robert Norden
Robert Norden
1,594 Points

Thank you for your response devvoyage! This really helps!