Add link rel="prev/next" to your blog

Google has been trying to improve the way it detects duplicate content on a website. URLs with parameters, such as the ones used for pagination, are tricky. You have the option to add a link tag to help Google identify this content. To read more about this check out the blog post in the Google webmaster blog.

To implement this in a Joomla template you can add the code in the overrides. For example you can open root/templates/your_template/html/com_content/blog.php. Inside it add this code:

// Add rel=prev/next
// http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
$doc =& JFactory::getDocument();
$pagdata = $this->pagination->getData();
if($pagdata->next->link){
 $doc->addHeadLink( $pagdata->next->link, 'next');
}
if($pagdata->previous->link){
 $doc->addHeadLink( $pagdata->previous->link, 'prev');
}

The variable $pagdata contains all the information about the pagination for the current page. We simply make a check for a next or previous page link. If there is one it means the page with other items exists so we can add the link tag. We do this with the addHeadLink function.

Rate this item
(2 votes)
Tagged under

16 comments

  • Comment Link Debbra Sunday, 19 May 2013 12:33 posted by Debbra

    This piece of writing will help the internet people for building up
    new webpage or even a weblog from start to end.

  • Comment Link Willie Saturday, 18 May 2013 16:39 posted by Willie

    Right away I am going away to do my breakfast, later than having my breakfast coming again to read other news.

  • Comment Link Halley Wednesday, 01 May 2013 11:56 posted by Halley

    Hi there, I enjoy reading through your article post.
    I like to write a little comment to support you.

  • Comment Link Http://Www.Slictraining.Org.Uk Monday, 15 April 2013 14:37 posted by Http://Www.Slictraining.Org.Uk

    Simply want to say your post is just as amazing.

  • Comment Link learn more Wednesday, 03 April 2013 07:48 posted by learn more

    Have you thought to add more pictures and videos?
    I think it might spruce this content up a little bit more.
    Not to imply it's bad, but I am a visual kind of man. No big deal, simply a idea.

  • Comment Link Antony Wednesday, 13 February 2013 08:11 posted by Antony

    Keep this going please, great job!

  • Comment Link Benny Tuesday, 29 January 2013 20:29 posted by Benny

    My brother suggested I might like this web site. He was totally right.

    This post actually made my day. You cann't imagine just how much time I had spent for this information! Thanks!

  • Comment Link Monisha Vohra Tuesday, 15 January 2013 19:23 posted by Monisha Vohra

    It's nice to see this site is finally getting the attention that it deserves Keep up the fantastic work.

  • Comment Link Harlan Monday, 20 August 2012 00:03 posted by Harlan

    Great blog here! Also your website loads up very fast!
    What web host are you using? Can I get your affiliate link to your host?

    I wish my site loaded up as quickly as yours lol

  • Comment Link homepage Thursday, 05 July 2012 01:36 posted by homepage

    Your style is very unique in comparison to other folks I have
    read stuff from. Thank you for posting when you have
    the opportunity, Guess I'll just bookmark this web site.

Leave a comment