<![CDATA[ Canonical URL tag in MODx - SEO trick - My Forums]]> https://forums.modx.com/thread/?thread=1937 <![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=4#dis-post-555718
<link rel="canonical" href="[[~[[*id]]? &scheme=`full`]]" />


i have 1 id to be the symlinks(index, follow) test1.html

and 3 other ids, being:
1 modDocument(noindex,nofollow) test2.html
1 modSymlink(noindex,nofollow) test3.html
1 modSymlink(noindex,nofollow) test4.html

all 4 id says they have the same canonical.

but the 3 ids should be pointing to my test1.html(because i have it indexed), which they dont

In my production site, and dev site, but for 1 reason, in development site is not workin. hows that possible?

]]>
jacielluve Dec 04, 2017, 11:14 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=4#dis-post-555718
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=4#dis-post-416723
I have a few different galleries on a site using gallery add on by splittingred and i am using friendly urls so thats all good and they look pretty but obviously my canonical url doesn't point to that gallery as its tag is not built into the code

So say i'm at:
http://www.example.com/gallery/kitchens/town+house+kitchen/

townhouse kitchen being the gallery, this page's canonical url would show as:

<link href="http://www.example.com/gallery/kitchens.html" rel="canonical">

Has anyone got any thoughts as to how i could reference the gallery name in the canonical url code?

Thanks,

Alex
]]>
alexmercenary Mar 20, 2012, 06:31 AM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=4#dis-post-416723
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=4#dis-post-401362
[[getParam]]

but better is to ditch the phx and have all that code in [!getParam!]
<link rel="canonical" href="[(site_url)][~[*id*]~][!getParam!]" />

]]>
mrhaw Nov 24, 2011, 04:23 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=4#dis-post-401362
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13226 markh Jun 20, 2011, 03:17 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13226 <![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13225
I need your comment/advice for another canonical link version I’m adressing, in Evo 1.0.5, and thanks for the code examples in that tread.

I’m using friendly url (with .php suffix) so
<link rel="canonical" href="[(site_url)][~[*id*]~]" />

is doing fine for most of my sites and pages.

There is one situation where I need somethimg in addition, as I’m adding a parameter with an integer value behind an alias, let’s say an url like www.domain.com/nice-page.php?parameter=8

I’ve done it with a snippet that is getting the parameter named [!getParam!] and added Phx to the above code example:
<link rel="canonical" href="[(site_url)][~[*id*]~][+phx:if=`[!getParam!]`:isnot=`0`:then=`?reg=[!getParam!]`:else=``+]" />


Unfortunately the if/then in the Phx (2.1.4) part does not work, even if the get parameter is 0 the then part will appear. The snippet is giving the right values, from 0 to n. Is there an issue with comparisons in Phx?

The snippet i use is

<?php
$region_id = $_GET['reg'];
if($region_id > 0) {print $region_id;}
else print "0";
?>


I know, it’s more a Phx question with comparison issues but maybe you find it useful here (if it works) and you can help.

Thanks!


]]>
hgw Jun 20, 2011, 03:08 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13225
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13224
<link rel="canonical" href="[(site_url)][~[*id*]~]" />


[(site_url)] is a system setting tag and gets replaced with ilovemodx.com when parsed.]]>
markh Jun 06, 2011, 07:39 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13224
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13223
My site has 3 diff templates used in 9 diff pages/URLS

My question:
Say the URL for my site is ilovemodx.com..

Do I paste this code on the head of each template LIKE THIS:

<link rel="canonical" href="[(site_url)][~[*id*]~]" />


OR LIKE THIS:
<link rel="canonical" href="[(ilovemodx.com)][~[*id*]~]" />]]>
ValpoCreative Jun 06, 2011, 07:25 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13223
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13222 BobRay Apr 26, 2011, 04:32 PM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13222 <![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13221 it is the case when all your pages are using SE friendly URLs but some of them can be accessed under more than one category as a consequence having more URL addresses each of them SE friendly but creating duplications
Yeah, if you’re linking to the exact same content at different URLs that would be a problem, and a perfect reason to use the Canonical tag, though it would be even better if you can just resolve the duplication such that the content only ever appears at the same URL.

If you can’t do that, then yeah, you’ll need some consistent scheme for deciding which URL should be canonical and indicating that. Hard to say more without details, but presumably if there is some logical rule for which version you want to be canonical, you should be able to write a snippet to implement that rule.

Generally I wouldn’t recommend setting up your site this way. If you want to list a resource under several different categories that’s fine, but set it up so that the resource always lives at the same URL regardless of where it’s being linked from.]]>
esnyder Apr 26, 2011, 11:57 AM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13221
<![CDATA[Re: Canonical URL tag in MODx - SEO trick]]> https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13220
As it stands, with
<link rel="canonical" href="[[++site_url]][[*canonicalTag]]" />

if [[*canonicalTag]] is empty the link will point to the home page of your site which will confuse the search engines and in the worst case result in the page not being indexed. Effectively you will be telling them ’the content on this page is the same as the home page, so please index that instead’.

Solution
You could fix this by adding to your template:
<link rel="canonical" href="[[++site_url]][[*canonicalTag:default=`[[*id:isnot=`[[++site_start]]`:then=`[[~[[*id]]]]`]]`]]" />

That will return the document url if your TV is empty. I would also consider changing it so you can just enter the resource id in the TV rather than the url alias to minimise typos. Easy mistake to make but can really mess things up!

Even better...
If there is a consistent rule for working out which is your ’original’ product page, consider a snippet which would generate the canonical link rather than doing it manually. Let modx do it all for you smiley]]>
okyanet Apr 26, 2011, 03:54 AM https://forums.modx.com/thread/1937/canonical-url-tag-in-modx---seo-trick?page=3#dis-post-13220