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

Tamas Dukai
Tamas Dukai
6,103 Points

Adding meta tags to pages

Just thought I'd share this with others. You can add different meta descriptions and keywords to your pages similarly how it's done with the title.

Add two variables, for example, in the index.php

$metaDesc = "This is a media library where you can find the latest books, music and movies."; $metaKeyw = "movies, music, books";

then go to header.php and add the following two lines after the <title></title> tag:

<meta name="description" content="<?php echo $metaDesc; ?>"> <meta name="keywords" content="<?php echo $metaKeyw; ?>">

Then just add the two variables to your other pages with different values.

Julien Steel
Julien Steel
10,790 Points

Cool! Thanks for the insight