Reputation:
This is more a "best practice" question than it is a coding question. In regards to coding your header/navigation and footer sections in a website. Is it better to code it on each page or use the includes tag?
Coding it on each page seems very tedious and violates the golden rule of "never repeat yourself", so using the includes tag seems like the most obvious choice but I could be wrong.
I'm average at best when it comes to best standards in web design so I'm looking to get some input from the pro's so to speak.
Just as a side note, as far as I know you need some kind of "desktop server" in your development setup to use the includes tag, me working straight from my desktop then won't be able to test with the includes tag, is this correct?
Thanks in advance!
Upvotes: 0
Views: 130
Reputation: 2523
You shouldn't repeat code. Imagine that you have to change your header one day... you must need to make the change on all your pages! That's an absolute no-no.
Upvotes: 0
Reputation: 1548
If your website is in PHP, then definitely use the include function for repeating content - not just the header/footer, but any repeating modules through the pages, too.
This means that any time you need to update your header, you don't need to do it separately on every page!
As for working locally - you can install PHP onto your computer, and have a local server environment to test with. If that seems daunting, then just upload to a test website before you upload to your live website, so you can use the PHP server there.
Upvotes: 3