I am working on some search engine optimisation for my ExpressionEngine site. I need to add some link tags into my head to allow Google crawlers to acknowledge the relationship between paginated pages in my blog.
I need to add:
<link rel="next" href="http://www.mysite.com/news/latest-news/P10" />
to the first news page, then:
<link rel="prev" href="http://www.mysite.com/news/latest-news/" />
<link rel="next" href="http://www.mysite.com/news/latest-news/P20" />
to the next page, and so on until the final page where I'll add
<link rel="prev" href="http://www.mysite.com/news/latest-news/PXX" />
I have been trying to achieve this by using the following code:
First news page:
{if last_segment == "latest-news"}
<link rel="next" href="http://www.6dg.co.uk/news/latest-news/P10" />
{/if}
This works fine, but for subsequent pages I have tried this, which does not work as PX is not accessible as a url segment.
{if last_segment == "P10"}
<link rel="prev" href="http://www.6dg.co.uk/news/latest-news" />
<link rel="next" href="http://www.6dg.co.uk/news/latest-news/P20" />
{/if}
{last_segment} returns latest-news.
Does anyone know how I can get round this issue?
I also have another issue with this method. Currently I only have 3 paginated pages, but this will go up as more entries are added, so I am not going to know what segment value to target in order to add my final link tag.
Any help will be greatly appreciated.
I am using ExpressionEngine version 2.2.2