[solved] Canonical URL on Products detail page

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

[solved] Canonical URL on Products detail page

Post by paulbaker »

Hi :D

I have an installation of Products on CMSMS 1.11.7 using pretty URLs. I call it with:

Code: Select all

{Products sortby="f:sortby"}
so it lists all Products on a page like "http://www.example.com/portfolio

I have the usual canonical call in the HEAD of the page template:

Code: Select all

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
So this produces the canonical link "http://www.example.com/portfolio on the main Products list page. So far so good.

When I click a Product to see more details it uses the same page template and goes to a URL like "http://www.example.com/portfolio/3/24/Nice-Product-Name

But the canonical URL in the HEAD remains as "http://www.example.com/portfolio

How can I change the canonical URL in the HEAD to match the real pretty URL of "http://www.example.com/portfolio/3/24/Nice-Product-Name ???

Thanks!
Last edited by paulbaker on Fri Oct 04, 2013 4:06 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Canonical URL on Products detail page

Post by calguy1000 »

Try this in your detail template:

{$canonical=$entry->detail_url}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: Canonical URL on Products detail page

Post by paulbaker »

Perfect :P

Thanks Calguy O0
Post Reply

Return to “Modules/Add-Ons”