We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46630
    • 40 Posts
    Hi! I would like to display the absolute url as canonical in the head of the website, but I couldn't find the way to do that if friendly urls are enabled. Also I have enabled "Use Friendly Alias Path" setting.

    This is my code:

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


    This returns the friendly url of the page.

    Thanks for the tips in advance. [ed. note: ispasov last edited this post 12 years, 6 months ago.]
      • 44234
      • 219 Posts
      What exactly does the following output?
      <link rel="canonical" href="[[++site_url]][[~[[*id]]]]">
        Find me on Twitter, GitHub or Google+
        • 22840
        • 1,572 Posts
        <link rel="canonical" href="[[~[[*id]]? &scheme=`full`]]" />
          • 46630
          • 40 Posts
          Quote from: davidpede at Mar 11, 2014, 10:49 AM
          What exactly does the following output?
          <link rel="canonical" href="[[++site_url]][[~[[*id]]]]">

          This outputs the full friendly URL of the resource.
            • 46630
            • 40 Posts
            Quote from: paulp at Mar 11, 2014, 11:54 AM
            <link rel="canonical" href="[[~[[*id]]? &scheme=`full`]]">

            This outputs the full friendly URL of the resource also.
              • 44234
              • 219 Posts
              When you say 'full friendly URL of the resource' do you mean 'http://www.website.com/some/page.html' or '/some/page.html'?
                Find me on Twitter, GitHub or Google+
                • 46630
                • 40 Posts
                Quote from: davidpede at Mar 11, 2014, 12:24 PM
                When you say 'full friendly URL of the resource' do you mean 'http://www.website.com/some/page.html' or '/some/page.html'?

                I mean the first, the full url -
                http://www.website.com/some/page.html
                .

                The second type ('/some/page.html') I can get if I write:
                <link rel="canonical" href="[[~[[*id]]? &scheme=`abs`]]">
                  • 46630
                  • 40 Posts
                  And may I make my question pore concrete:

                  Do I need the absolute URL as a canonical link if it's not active link and points to 404 page. I mean that modx is not like drupal where http://website.com/node/6 is active link and points directly to the friendly url - for example http://website.com/category/page.html ?
                    • 44234
                    • 219 Posts
                    If friendly url's are enabled and
                    [[++site_url]][[~[[*id]]]]

                    and
                    [[~[[*id]]? &scheme=`full`]]

                    are outputting
                    http://www.website.com/some/page.html

                    then that is correct behavior.

                    Tbh I'm not understanding what you are trying to do as I'm not familiar with Drupal.
                      Find me on Twitter, GitHub or Google+
                      • 46630
                      • 40 Posts
                      Quote from: davidpede at Mar 11, 2014, 12:50 PM

                      Tbh I'm not understanding what you are trying to do as I'm not familiar with Drupal.

                      Well maybe I am wrong but as far as I know about canonical links they have to be urls which are static and never change. So I want to inform the search engines that this is the static link and if the url of the resource has changed (the resource is moved under different parent resource) the canonical url stays the same.

                      Maybe someone could give me better approach to do this.