canonical tag difference for pages and news with pretty url

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
userwords
Forum Members
Forum Members
Posts: 48
Joined: Mon Dec 27, 2010 12:27 am

canonical tag difference for pages and news with pretty url

Post by userwords »

my config
  • cms made simple 1.9.2
    pretty url mod rewrite configured
    handwritten urls for pages and news
    installed on xampp as i build a web
    added the detailpage="somealias" parameter to news tag
Ive found something weird. If you enable pretty url following wiki instructions using mod rewrite method and writing your desired url for every new page, you get it working. Then you can look at how cms made simple filled the canonical tag for that page and it is correct:

page url http:\\www.mydomain.com\my-pretty-url-page

canonical tag fill with the same <link rel="canonical" href="http:\\www.mydomain.com\my-pretty-url-page/> (actually the correct one pretty url for the page)

BUT

It is not working as it should for news. If you fill the url option when writing news to get pretty url, you get the page on the correct url BUT not on the canonical tag that takes the initial url instead

news detail page url http:\\www.mydomain.com\my-pretty-url-news-detail-page

canonical tag fill with the default url not the pretty one <link rel="canonical" href="http:\\www.mydomain.com\news\1\15\my-pretty-url-news-detail-page/> (actually not the pretty url :D)

So cms made simple is using the pretty url to fill canonical tag for pages. But for news pretty url is working but it is not using it to fill the canonical tag. Hence creating some duplicity here because when browsing your web visitors and i suppose that spiders will reach news detail pages on the pretty url but then spiders will find the canonical tag on those detail pages telling them to use another url which in fact is heavier than the one they found the news detail on.

Is this some bug or maybe something it was missed for this latest version of cms made simple. I really think that the pretty url set for news should be used instead to fill the canonical tag to keep indexing and browsing urls homogeneous.

If not using the pretty url of news detail page to fill the canonical tag then search index in search engines will show to potential visitors the wrong url and they will enter always the page from the wrong url.

Unless i missed something when configuring pretty urls or putting some tag, in which case i would like to hear wht i did wrong.

UPDATE

ive spent lot of time reading every step to make this work again and all seem to be correct, i found these post:

http://forum.cmsmadesimple.org/viewtopi ... ws#p176673

and

http://forum.cmsmadesimple.org/viewtopi ... ws#p149017

and all what they ask on them is where it should, so im lost on why is default url used for news detail page even if you give them a handwritten url in their options with pretty url working and they actually show under that pretty url.

NOTE TO ADMIN

Dr.Css if you browse the first post all way down there is something broken in that post, i dont know if it is important wanted you to know in case there is some som bug in the forum.


UPDATE

Is there anything i can do to this line in the template to get it working

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}

Ive being trolling around but my knowledge is limited to html and css, i can sometimes guess wht some php or cms logic is doing but im very limited on that. Wht i know is that probably this method to gather canonical url for a page works when pretty url are activated using mod rewrite, but NOT for news. For news this method is getting default url for the news post instead of the pretty one when pretty url is activated.

Ive also found that inside data base there is a value called news_url in cms_module_news table
thats the url field you fill when writing some news so i suppose it is a matter of some logic of the kind

if news_url value is set for this news
then canonical tag uses something like
[[root_url]]/news_url

if not get default one
http:\\www.yourdomain.com\\09\\29\\your-news-title
dazzyweb
Forum Members
Forum Members
Posts: 29
Joined: Mon May 30, 2011 1:21 pm

Re: canonical tag difference for pages and news with pretty

Post by dazzyweb »

What i did with this problem was to add an extra field in news called canonical_url and in this field put the url that i would like to be the canonical.

Then in the head section of the template that the news module uses i put the following to pull in the url i wanted to be canonical.

{if isset($entry->lesson)}
<link rel="canonical" href="http://www.yoursite.com/{$entry->canonical_url}" />
{/if}

and deleted the following from the head

<link rel="canonical" href="{$canonical}" />

not sure if this is the best way of doing things but works fine and got around the problem.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: canonical tag difference for pages and news with pretty

Post by carasmo »

Code: Select all

{if isset($entry->canonical)}
  {assign var='canonical' value=$entry->canonical}
{/if}
Put this in the news detail template inside news -- not on the template that is the pagealiase and it works great, no need to add extra fields.
Post Reply

Return to “CMSMS Core”