We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18367
    • 834 Posts
    Hi,

    below is the code i use for all my sites for canonical issues and so far it's worked ok
    <base href="[[!++site_url]]" />
    <link rel="canonical" href="[[++site_url]][[*id:isnot=`[[++site_start]]`:then=`[[~[[*id]]]]`]]" />


    However, on my latest site it is refusing to be saved by Modx.

    All sites are on the same server and running the same version of Modx Revo 2.5.7

    By trial and error I deduced it was the last bit that was causing the problem
    [[~[[*id]]]]`]]


    And in particular the
    [[~[ ]]


    So I rewrote it as
    <link rel="canonical" href="[[++site_url]][[*id:isnot=`[[++site_start]]`:then=`[[*id]]`]]" />


    Just to see what would happen. It worked ok except I got the id number in the url instead of the alias.

    So I changed it to "alias"
    <link rel="canonical" href="[[++site_url]][[*id:isnot=`[[++site_start]]`:then=`[[*alias]]`]]" />


    That seems to have worked but not sure if it's correct code syntax without the tilde and the extra brackets.

    Plus I still don't know why the original code won't save.

    Anyone got any ideas?

    Thanks


      Content Creator and Copywriter
      • 3749
      • 24,544 Posts
      The fact that you have one cached and one uncached site_url tag could be a factor.

      You might try the Canonical extra, which injects the canonical tag for you when it's appropriate.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting