Polishing Thematic’s Head

I apologize in advance for the subtle sexual innuendo throughout the post, but I will be focusing on the “Head” of a Thematic Theme Framework child theme. Unless you are a code Nazi you may have not noticed Thematic’s head is a little bloated, even right out of the box (zip?). There is just some markup that does not need to be in the head of the document. After a short time of working on a child theme, especially adding plugins, the head of your document will be unnecessarily swollen. Hopefully this set of snippets for your functions.php file will let you relieve some of that stress.

Modifying the Thematic Robot Meta

Ok, the way Thematic is set up for SEO is really good, so by default you won’t be having duplicate content issues. But… if you view source you may see this guy in there.


<meta name="robots" content="index,follow" />

This just rubs me the wrong way. Why? Because it is the browser default, having nothing there would tell the browser the same thing as this meta tag. So removing it seems like a good way to clean things up. The code below just removes the line and moves a little structure around for correct spacing, that’s it. Simple.


// remove the index and follow tags from header since it is browser default. 
// http://scottnix.com/polishing-thematics-head/ 
function childtheme_create_robots($content) { 
  global $paged; 
  if ( thematic_seo() ) { 
    if ( ( is_home() && ($paged < 2 ) ) || is_front_page() || is_single() || is_page() || is_attachment() ) { 
      $content = ""; 
    } elseif ( is_search() ) { 
      $content = "\t"; 
      $content .= "<meta name=\"robots\" content=\"noindex,nofollow\" />"; 
      $content .= "\n\n"; 
    } else { 
      $content = "\t"; 
      $content .= "<meta name=\"robots\" content=\"noindex,follow\" />"; 
      $content .= "\n\n"; 
    } 
      return $content; 
    } 
  } 
add_filter('thematic_create_robots', 'childtheme_create_robots');

Removing Duplicate Canonical Tag in Thematic

Don’t ask me why there are two canonical tags called on single() pages, while they won’t cause any harm, they just look bad in your markup. I have only tested this with Yoast’s WordPress SEO plugin, but with almost any WordPress Plugin you will still get 2 canonical tags, it has to be a Thematic issue, but oh well. Lets fix that.


// remove Thematic canonical tag
function childtheme_canonical_url() {
// silence
} 
add_filter('thematic_canonical_url', 'childtheme_canonical_url');

This was reported to the Google code project section where Thematic issues are held, hopefully it gets resolved.

Update: Looks like my report was accepted and the duplicate content issue was resolved on revision r774, awesome. Which makes the above snippet no longer needed for Thematic 1.0+

Even more, not Thematic specific though.

Some people may not be as excited about this last one as the previous two, but there are a few more things that I don’t use, or don’t need. I have commented what they are so you can search around to find more about them, but I am still yet to use them. This code snippet removes up to 6 lines of code from the head depending what page you are on and will work with any WordPress installation, not just Thematic.


// clean up some useless unneeded links in the head section
// remove really simple discovery
remove_action('wp_head', 'rsd_link');
// remove windows live writer xml
remove_action('wp_head', 'wlwmanifest_link');
// remove index relational link
remove_action('wp_head', 'index_rel_link');
// remove parent relational link
remove_action('wp_head', 'parent_post_rel_link');
// remove start relational link
remove_action( 'wp_head', 'start_post_rel_link'); 
// remove prev/next relational link
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head');
 // remove wordpress version (security issue), not needed for thematic
remove_action( 'wp_head', 'wp_generator');

Now someone might say but “OMG, removing the previous/next, parent and index relational links are bad for SEO!”. To that I say prove it. I just look at it as one less way to control how your pages link if you were really working on solid structure (information architecture) since it links what was literally previous or next even though they may not be related.

Is that it for cleaning up Thematic’s head?

Nope, depending on what plugins you are using or jQuery you have loading in WordPress, there could be a ton of other things. Originally this post contained some other best practices, but I only scratched the surface and the information would probably raise a lot of questions so I removed it till I can provide more comprehensive information. Instead this post will focus on the first few things you may want to do with a child theme to tidy up a bit.

One Comment

  1. You’re website is great. Thank you for the information. I’ll definitely be using some of your code.

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*