I have many pages on my website and the navigation bar is the same on every single page. Is there any way to include this navigation bar on my page that is more efficient than just having the same exact HTML code on every page?
Kinda thinking like the php include function. You know?
Yes, PHP includes are a good way of doing that. Where you write the code snippet in a separate file to be included and then on the pages where you want it placing add the include instructions.
Thus allowing you to save time; instead of manually adjusting duplicate navigation menus on each individual page, etc.
To use server-side includes (SSI), save the code that you want repeated on each page as an HTML fragment - ie, save it as a .htm file, just as it is, don’t include all the doctype, head and body tags. Then on each page, you need something like:
<!–#include virtual=“/menu.htm” –>
You can use root or relative links, but you can only include files on the same domain.
You then need to save your main files as .shtml or instruct the server to treat all .htm/.html files as shtml.