how to deal with headers and footers in website coding?

Santuzzo

Daemon Poster
Messages
675
Location
Amsterdam, The Netherlands
I have a website that consists of several pages, all of which share the exact same header (which is the navigation-menu) and the same footer.
Every time I make a small change in either the header and/or the footer I have to apply that change to every site.
How can I do this more easily so that I have to do the changes in the header of footer only once and those changes are applied to all the sites that have the footer and header?
My page is all html files, and I remember using php include for the header and footer in my old site, but at some point that just stopped working.
 

OK, thank you, I will need to look into this.

I am using scripts on my website, so I'd think scripts are not blocked, but I'm a beginner with all of this, so I'm not sure ....

What is a general or common practice in this scenario? I see lots of website that have several pages and on each page the header (usually the navigation menu) and the footer are exactly the same. Is it commonly done to have the header and footer in each file, so if either needed a change, this change would have to be applied to every single file/site?
Or is the above suggested jQuery solution (which I still need to look into, I haven't had the time to do that yet) commonly used in these cases?
 
OK, thank you, I will need to look into this.

I am using scripts on my website, so I'd think scripts are not blocked, but I'm a beginner with all of this, so I'm not sure ....
Scripts are not blocked unless the end user has a script blocker, ad-blocker, or JavaScript disabled in their browser. The most you can do then is use the <noscript> tag to basically say "hey, turn on scripts if you want this site to function and look like it was meant to."

What is a general or common practice in this scenario? I see lots of website that have several pages and on each page the header (usually the navigation menu) and the footer are exactly the same. Is it commonly done to have the header and footer in each file, so if either needed a change, this change would have to be applied to every single file/site?
Or is the above suggested jQuery solution (which I still need to look into, I haven't had the time to do that yet) commonly used in these cases?

Most sites will be using a back-end server, and have something like PHP, .NET, etc. as the back end for the site, and those languages all support templates. The jQuery method above is all run client-side (because it's JavaScript). So if your site isn't running on a server-side language like one mentioned above, the jQuery method is going to be your best bet so that you don't have to have the header/footer individually on each page; you can template it and load it from a single file and then make any necessary changes to those single files.
 
Scripts are not blocked unless the end user has a script blocker, ad-blocker, or JavaScript disabled in their browser. The most you can do then is use the <noscript> tag to basically say "hey, turn on scripts if you want this site to function and look like it was meant to."



Most sites will be using a back-end server, and have something like PHP, .NET, etc. as the back end for the site, and those languages all support templates. The jQuery method above is all run client-side (because it's JavaScript). So if your site isn't running on a server-side language like one mentioned above, the jQuery method is going to be your best bet so that you don't have to have the header/footer individually on each page; you can template it and load it from a single file and then make any necessary changes to those single files.

Thank you very much!
For the back-end server option that you mentioned I assume I'd need to have a special type of web-hosting plan, as in having a server all for myself? Would that be what they call VPS-hosting?
 
Thank you very much!
For the back-end server option that you mentioned I assume I'd need to have a special type of web-hosting plan, as in having a server all for myself? Would that be what they call VPS-hosting?

VPS is a type of server. But yes, you would need some type of hosting service that's running on a webserver with whatever runtimes/framework your site needs to run, installed.
 
Back
Top Bottom