I have a test site running MODx Revolution 2.0.0-rc-1 rev6614 and had a question regarding Canonical URL links in Revo.
FYI, my site is NOT installed in the root of the domain, and I am also running with Friendly URLs, Friendly Aliases, and Friendly Alias Path all set to
Yes
The following code appears to work as expected for all pages
except the home page:
<link rel="canonical" href="[[++site_url]][[~[[*id]]]]" />
Output on home page:
http://domain.com/~username/modx/revolution//~username/modx/revolution/
Output on other pages:
http://domain.com/~username/modx/revolution/alias.html
I was able to find a solution by altering the output when on the home page using:
<link rel="canonical" href="[[++site_url]][[*id:isnot=`[[++site_start]]`:then=`[[~[[*id]]]]`]]" />
I am curious why I have to do it this way? Why does
[[~[[*id]]]] come through differently on the home page than the other pages on the site?
/~username/modx/revolution/ vs.
alias1.html or
alias2.html
Is there a better way to go about outputting the valid page URL (minus query string) in Revo? Even if
[[~[[*id]]]] came through as
/, you’d end up with a trailing double slash
// if only using
[[++site_url]][[~[[*id]]]], so is the conditional check on the home page required either way?
NOTE: This same behavior is occurring for my homepage entry in my XML sitemap generated from 3PD Add-on:
googlesitemap-1.1-rc1