This is second article in the "Do it yourself" series and this one will be about heading tags.
Most theme authors still do not pay particular attention to the layout and usage of header tags (H1, H2, H3...) in theme layouts. From the HTML optimization perspective, H1 is the most essential page tag and should appear as first on the page, and only once.
H2 tags is next in hierarchy and you can have several of them on the page. Below each H2 you can have several H3 tags and so forth. H3 and H4 are not as important, but having H1 and H2 correct on your page is (at least from the HTML semantic point of view!).
Two most important pages on your site will probably be the home page and the single article page. The preferred layout for these pages is as following.
- Blog title OR Blog Description H1
- Post titles H2
- Blog title and Blog description no heading (just a simple <p>)
- Post title H1
- Headings inside the post H2 and lower
To achieve this layout can modify your theme code in several ways. Here is what I did in mine, file header.php:
<?php if (is_home()) echo '<h1>'; else echo '<p class="description">'; if (current_user_can('level_10')) echo '<a href="'.get_settings('siteurl').'/wp-admin/">'; else echo '<a href="'.get_settings('siteurl').'/">'; bloginfo('description'); if (is_home()) echo '</a></h1>'; else echo '</a></p>'; ?>
What this code does is embed my blog description in H1 tags if on home page and also ads a link to the wordpress admin if I am logged in. It does this with following:
- In case of home page (is_home() check) it outputs <h1> else it outputs a <p>
- Next comes the link. If I am logged in as admin (current_user_can('level_10')), blog description will actually point to my wp-admin, otherwise it will point to my home page. This is only for my convenience
- Then comes the printing of the actual blog description, and closing the tags afterwards
Next part of the exercise is to print your post titles in H2 in your index.php, and as H1 in single.php and page.php of your theme:
<h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
This simple change tells the search engines what is important on your page, and allows them to make a better decision on what should they rank you for.
More like this:
- Do it Yourself: Optimize your WordPress Site Titles
- Tweaking WordPress: Home page tweaks
- Ask the WordPress Guru, Q&A #1
Posted in: WordPress
TAGS:blog headings wordpress, diy optimize wordpress blog, diy workpress page, heading plugin wordpress, headings archive pages wordpress, headings wordpress, link same page headings, optimized title wordpress single, page headings, page rank headings, title wordpress page, wordpress api, wordpress headings, wordpress headings optimization, wordpress optimization, wordpress page primary link, wordpress pages headings, wordpress pages links different, wordpress pages lower case, wordpress theme headings