Improved Search Engine Indexing

Oct 22, 2007

I've tweaked this site to use an improved means of search engine indexing. WordPress ships with a less than perfect SEO setup. As such, many incoming search queries were hitting pages that no longer included the requested terms: stuff like archive pages, category pages, etc. This duplicate content problem was easily solved by using the following snippet of code in my header.php file:

if(is_home() || is_single() || is_page())
    echo "\t<meta name=\"robots\" content=\"index,follow\" />\n";
else
    echo "\t<meta name=\"robots\" content=\"noindex,follow\" />\n";

I now ask search engines to only index those pages that are either a single post, page, or the home page itself (my photo album also gets indexed, but that's handled by the photo album software itself). Nothing else gets indexed, but all page links are followed, so that the target pages can be indexed as necessary. This should lead to improved search engine hits, leading people directly to the content they were looking for. Win-win for the user and for me.

3 Comments

Gary

10:49 AM on Oct 22, 2007
I don't think you want is_home() in that expression. With it you'll still get hits on temporary content from the home page summary. Shouldn't the home page be treaded like any other archive page?

Jonah

6:22 PM on Oct 22, 2007
I added the is_home() test after seeing it in a number of examples from around the web. Wouldn't this be necessary to have the root page indexed? Suppose someone searches for "Year of the Code Monkey" ... shouldn't they get the root page, and not a particular post or page? I originally tried doing (is_home() && $paged < 2), but I found that the $paged variable was null on the home page. I guess I could add an additional test for that, ensuring that the search engine only indexes the home page (and not the older, paginated posts).

??

6:17 PM on Oct 25, 2007
if this snippet works well, I'd expect wordpress might want to add the snippet to whatever cookbook they may provide wp users. I'm guessing at all of this, being an appreciative visitor, but also not being the "cms" type of person.

Leave a Comment

Ignore this field:
Never displayed
Leave this blank:
Optional; will not be indexed
Ignore this field:
Both Markdown and a limited set of HTML tags are supported
Leave this empty: