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

Nate Sprague
8,218 PointsConsistent Header throughout a Website
What is the best practice for dynamically pulling the same header, footer and any other elements that are consistently the same throughout an entire website?
2 Answers

jacobproffer
24,604 PointsHey Nate,
If you're using PHP, you can just include your header and footer on any of your pages, such as your index and sub-pages. From an agency standpoint, I would consider that to be best practice. This becomes more regular if you're working with WordPress.
For sections you're going to re-use throughout your site, such as a testimonial slider, I would also use includes but place those elements inside of a folder typically labeled 'modules'.

Dave Berning
17,365 PointsHi Nate,
If you are creating a website from scratch, the best practice is to use PHP. Nothing too crazy but this can easily be achieved via PHP "includes".
<?php include "path/to/header.php"; ?>
You can also use this to dynamically generate a sidebar or other sections.