We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8531
    • 12 Posts
    Hi,
    I'm trying to get a rel="canonical" / rel="next" / rel="prev" out of this paginated sites - but everything I try is not working.
    At first:
    I'm using getPage for Pagination, and before I started to paginate sites I did this canonical-thing very easy via TV:
    [[*canonicalTag:notempty=`<link rel="canonical" href="[[*canonicalTag]]" />`:default=`<link rel="canonical" href="http://www.domain.tld/[[*uri]]" />`]]

    ...with getPage I started like this:
    [[*canonicalTag:notempty=`<link rel="canonical" href="[[*canonicalTag]]" />`:default=`<link rel="canonical" href="http://www.domain.tld/[[*uri]]&page=[[+page]]" />`]]

    ...but now I want to set the rel="canonical" only to the first site and I want to use the rel="next" / rel="prev" for the paginated sites....but I despair on this since days.

    Are there some ideas?
    • If I understand correctly, you're saying that you want the canonical tag to point to the first page in the series of pages, but you also want to use rel="next" and rel="prev"?

      My advice on that, for what it's worth, would be don't do it that way. The whole point of using the rel="next" and rel="prev" attributes is that you are telling search engines that you want them to index the next and previous pages as separate pages. But by having the canonical link element pointing to the first page, you are telling search engines that you want them to treat all of the subsequent pages as duplicates of the first page and ignore them. So that's a contradiction, and I'm not sure how search engines will interpret it.

      If you're going to use rel="next" and rel="prev" you should have the canonical tag point to the actual full URL of whatever page is being displayed, as you were originally doing if I understand you correctly.

      Also, there's no need to use a TV for the canonical unless you really want to for some reason - generally it's better to use this:

      <link rel="canonical" href="[[++site_url]][[*id:isnot=`[[++site_start]]`:then=`[[~[[*id]]]]`]]" />
      


      See this thread: http://forums.modx.com/thread/?thread=44222&i=1&page=1
        • 15877
        • 55 Posts
        I am also trying to implement a SEO friendly page navigation in MODx (on both Evo and Revo websites BTW).

        After reading this pagination guide, there are several methods to handle it:

        • noindex, follow on every paginated page except the first
        • see all page with a canonical pointing towards it
        • rel="previous" and rel="next" in the page head

        I have read that rel="noindex" did not work on anchor links.

        So it seems to me that the first method is the one that suits my case the best.

        But what method would you recommend to have <meta name="robots" content="noindex,follow" /> ONLY on paginated pages?
        • Quote from: kilroy at May 13, 2014, 08:59 AM
          what method would you recommend to have <meta name="robots" content="noindex,follow"> ONLY on paginated pages?
          I think it would be easy enough to do this with a modified version of the snippet I described in the original post. Instead of selecting unique titles and descriptions for paginated pages, the snippet would just set your meta tags the way you want them, like this:

          $properties =& $scriptProperties;
          $properties['page'] = (isset($_REQUEST[$properties['pageVarKey']]) && ($page = intval($_REQUEST[$properties['pageVarKey']]))) ? $page : 1;
           
          if ($properties['page'] == 1) {
              $modx->setPlaceholder('paginated-metas', '<meta name="robots" content="index,follow" />');
          }else{
              $modx->setPlaceholder('paginated-metas', '<meta name="robots" content="noindex,follow" />');
          }
          
          


          Then just put the placeholder [[+paginated-metas]] in your <head>
            • 8531
            • 12 Posts
            ...hmmm...don't know why - but in my case this is always showing the 'if' (== 1), never the 'else' (!= 1).

            this:
             <head>
              <meta name="test2" content="[[+page]]" />
              [[+paginated-metas]]


            returns:
            <meta content="3" name="test2">
            <meta content="index,follow" name="robots">


            [[+page]]=3
            [[+paginated-metas]]=1
            ..?
            • Hi effect-energy, I'm not sure why that is, but now that I think about it, the best way to do what kilroy was talking about is probably to just use an output filter on the page placeholder. Put this in the <head>:
              [[!+page:is=`1`:then=`<meta name="robots" content="index,follow" />`:else=`<meta name="robots" content="noindex,follow" />`]]
              


              That's a lot simpler than trying to figure it out inside a snippet and then return the appropriate tag.
                • 15877
                • 55 Posts
                Quote from: esnyder at May 20, 2014, 04:34 PM
                Hi effect-energy, I'm not sure why that is, but now that I think about it, the best way to do what kilroy was talking about is probably to just use an output filter on the page placeholder. Put this in the :
                [[!+page:is=`1`:then=`<meta name="robots" content="index,follow">`:else=`<meta name="robots" content="noindex,follow">`]]
                


                That's a lot simpler than trying to figure it out inside a snippet and then return the appropriate tag.

                Thank you for this solution, but for me, it only works if I put it after the getPage call.

                If I put the code you provide in the <head>, it only returns noindex, follow, even if it is on the first page.

                Here is the getPage call I use in my page body:
                [[!getPage@langfr?
                   &elementClass=`modSnippet` &element=`getResources` &parents=`[[*id]]` &depth=`1` &limit=`2` &pageVarKey=`page` &includeTVs=`1` &processTVs=`1` &showHidden=`1` &tpl=`actualite-lien` ]]


                If I put [[+page]] in the head, it returns the relevant value.
                • You could call getPage at the top of the template with toPlaceholder set to 1, and then insert the actual content in the right place using the placeholder.
                    • 15877
                    • 55 Posts
                    I have found an easier way to do it.

                    I place a snippet like this on every template that uses getpage :

                    <?php
                    
                    if (isset($_GET["page"]))
                    {
                       echo'<meta name="robots" content="noindex,follow" />';
                    }
                    
                    else {
                    	echo'<meta name="robots" content="index,follow" />';
                    }
                    ?>


                    Make sure it is uncached.
                      • 36613
                      • 328 Posts
                      I don't uderstand what i have this results:
                      <link rel="next" href="domainname.com/risultati-di-ricerca.html?search=prova&searchsb=Cerca&page=3" /> 
                      
                      <link rel="prev" href="domainname.com/risultati-di-ricerca.html?search=prova&searchsb=Cerca&page=1" /> 


                      I head part of page?