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

Business SEO Basics Better SEO Through Code Meta Description and Meta Keywords

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Title and meta tags for SEO with PHP

How do you create unique titles and meta tags for each page (via the header) on your site if your site is built with PHP with a single header.php file that is included on each page?

Thanks!

2 Answers

Seth Kroger
Seth Kroger
56,414 Points

The details will depend you're specific code/framework/etc. The basic part is to provide variables for title and search keywords before calling on the header file and use those to dynamically create the title and meta tags.

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Thanks for the quick response Seth. I'm not using any PHP frameworks at this moment, though I have been studying and learning a bit about Wordpress and have a few projects that I am working on utilizing the WP way.

So basically if I'm not using any particular PHP framework (ie., just a plain php site) all that I need to do is create the variables for both the title and the description/key words and echo them out (before the header include) on each page? I just want to make sure that I understand. If that's it, then it's not as complicated as I had anticipated (yay!).

I am a bit new in this field please guide me. What do you mean by variables?