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

PHP

What is better? Include header and footer php files into single content page or include content to index file?

I ask this due to performance issues and search issue due to google search engine. Is it better to include header.php and footer.php into various content php files or include content to one file (index.php which already has header and footer) and change the content based on the page the user by getting the page url parameter.

1 Answer

Hey Christophe,

I'm not sure if there's a right or wrong way to do this, but personally I would have a single index.php file which contained the header and footer contents, into which I would include the various content/template files.

This may be controversial however as the highly popular system Wordpress requires developers to use <?php get_header(); ?> and <?php get_footer(); ?> functions into each template they build.

I think ultimately it comes down to your personal preference as a developer but also, what it is you're attempting to build. :)

I hope this helps!

Best, Patrick