sorry if this question seems a bit open ended, but I’m often wanting to add new pages to my website. As my website grows, this means I’m having go back and add a link to the new page on all of my previous pages, which is becoming increasingly time consuming. Is there any way around this? An automatic method? Obviously in an ideal world you’d get the template page correct first, but this doesn’t seem to allow for easy expansion. How do the big sites cope? Thanks.
Share
You user server-side includes.
In PHP there are
include()andrequire()include('filename.php')will add the contents of ‘filename.php’ to the page it was included on. Require does the same thing, but the script stops if it can’t locate or use the file.Instead of doing:
Put it in a file called “navbar.html” and just do:
In your include file you could have:
And then in the PHP file:
It would be the same as doing:
…except that you can change the include file so that it changes every page. The output of either would be:
Goodluck!