<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Atomic Playboy&#187; HTML</title>
	<atom:link href="http://atomicplayboy.net/blog/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://atomicplayboy.net</link>
	<description>All hail the mushroom cloud</description>
	<lastBuildDate>Sat, 22 May 2010 19:43:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Canonical URLs in WordPress</title>
		<link>http://atomicplayboy.net/blog/2009/03/05/canonical-urls/</link>
		<comments>http://atomicplayboy.net/blog/2009/03/05/canonical-urls/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 16:26:50 +0000</pubDate>
		<dc:creator>Johan Svensson</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://atomicplayboy.net/?p=650</guid>
		<description><![CDATA[Like any good obsessive-compulsive blogger, I frequently pour over my web site statistics looking for interesting stuff. One thing that caught my eye is that search results coming in from Google tends to link to threaded comment pages for entries. For example, I&#8217;d get hits to /blog/2009/03/05/entry-slug/comment-page-1/, which is an URL that&#8217;s pretty hard to [...]]]></description>
			<content:encoded><![CDATA[<p>Like any good obsessive-compulsive blogger, I frequently pour over my web site statistics looking for interesting stuff. One thing that caught my eye is that search results coming in from Google tends to link to threaded comment pages for entries.</p>

<p>For example, I&#8217;d get hits to <tt>/blog/2009/03/05/entry-slug/comment-page-1/</tt>, which is an <span class="caps">URL </span>that&#8217;s pretty hard to actually find on the page &#8212; it&#8217;s only used for permanent links to entry comments, with an anchor to the comment ID tacked on, <a href="http://atomicplayboy.net/blog/2009/02/23/spotify-bay/comment-page-1/#comment-49949">like this</a>.</p>

<p>What I&#8217;d prefer to see is incoming hits to the actual blog entry <span class="caps">URL </span>&#8211; <tt>/blog/2009/03/05/entry-slug/</tt> in this case. Luckily, there&#8217;s a smart and simple solution &#8212; canonical <span class="caps">URL</span>s. The Google Webmaster blog <a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html">explains it nicely</a> with examples.</p>

<p>So I simply add a canonical tag referencing the preferred <span class="caps">URL </span>in each page. Now, it&#8217;s just the <em>preferred</em> <span class="caps">URL </span>on my side &#8212; this is just a hint to search engines that tells them that this page is a duplicate, and that I&#8217;d prefer them to let results point to one particular page of these duplicates. In 99% of the cases it will be respected, though.</p>

<p>The actual code is just a few lines. Add this in <tt>header.php</tt> of your theme, somewhere in the head:</p>




<pre><code>
&lt;?php if (is_singular()) { ?&gt;
&lt;link rel="canonical" href="&lt;?php the_permalink() ?&gt;" /&gt;
&lt;?php } ?&gt;
</code></pre>




<p><tt><a href="http://codex.wordpress.org/Conditional_Tags#A_Single_Page.2C_Single_Post_or_Attachment">is_singular</a></tt> is a function that returns true if any of <tt>is_single()</tt>, <tt>is_page()</tt> or <tt>is_attachment</tt> return true &#8212; in other words, if you&#8217;re currently visiting a single entry, a page or an attachment.</p>

<p>With this, each entry sub-page of comments has the main entry <span class="caps">URL </span>as their canonical <span class="caps">URL.</span> Now to wait a few days and see when the search engines<sup class="footnote"><a href="#fn1">1</a></sup> pick up the change.</p>

<p class="footnote" id="fn1"><sup>1</sup> And by &#8220;search engines&#8221; I mean &#8220;Google.&#8221;</p><script src="http://feeds.feedburner.com/~s/AtomicPlayboy?i=http://atomicplayboy.net/blog/2009/03/05/canonical-urls/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://atomicplayboy.net/blog/2009/03/05/canonical-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: atomicplayboy.net @ 2012-02-11 04:39:45 -->
