possibility for <link rel="canonical" ...?
Permalink 1 user found helpful
Hi all,
Is there any possibility to make use of the <link rel="canonical" href=" ...-tag with the pretty URL shown?
I experienced, that links in a template (where that tag should also be placed) are not rewritten.
Any ideas?
Thx in advance,
Sven
Is there any possibility to make use of the <link rel="canonical" href=" ...-tag with the pretty URL shown?
I experienced, that links in a template (where that tag should also be placed) are not rewritten.
Any ideas?
Thx in advance,
Sven
you could try to output $c->getCollectionPath() in your header.php (in your theme)
Thanks Remo for the fast reply. That'll do.
I also tried to google with my search phrase (C5 forum didn't show a suitable post) and found that following thread. ;)=
http://www.concrete5.org/community/forums/customizing_c5/canonical_...
I also tried to google with my search phrase (C5 forum didn't show a suitable post) and found that following thread. ;)=
http://www.concrete5.org/community/forums/customizing_c5/canonical_...
yeah c5 forum search isn't perfect..
I usually search like this "site:concrete5.org canoncial", works better imho
But what you found is pretty much what I've meant! His version is actually better because the url includes http etc., getCollectionPath doesn't
I usually search like this "site:concrete5.org canoncial", works better imho
But what you found is pretty much what I've meant! His version is actually better because the url includes http etc., getCollectionPath doesn't
but be careful with this, I doubt any of these two version will generate "real canonical urls". If there's some dynamic stuff in it, it probably won't work
(e.g user info block where parameter changes content)
(e.g user info block where parameter changes content)
Okay, but I just need it to get rid of the "index.php" in URLs that Google has indexed.
I really don't know, how they got there. The page was made public with "pretty URLs on" and i cannot find any link using that format.
Thanks a lot again anyway.
Sven
I really don't know, how they got there. The page was made public with "pretty URLs on" and i cannot find any link using that format.
Thanks a lot again anyway.
Sven
i recognized that issue too. When adding links to page via tiny mce, index.php is in the href="...".
If your pretty urls are working, try the solutions described athttp://www.concrete5.org/community/forums/documentation_efforts/pre...
If your pretty urls are working, try the solutions described athttp://www.concrete5.org/community/forums/documentation_efforts/pre...
Hey there,
I made that out of it. I experienced, that if cID=1 (I think that's (mostly) the main page) the URL generated washttp://domainname.tld/index.php?cID=1...
Don't know why, but this works for me.
I made that out of it. I experienced, that if cID=1 (I think that's (mostly) the main page) the URL generated washttp://domainname.tld/index.php?cID=1...
Don't know why, but this works for me.
<? if ($c->getCollectionId() == 1) { $canonical = 'http:// domainname.tld/'; // perhaps there's a global variable for that } else { $url=Loader::helper('navigation'); $canonical=$url->getCollectionURL($c); } ?> <link rel="canonical" href="<? echo $canonical; ?>" />
My method is similar, but not hard-coded to a specific site:
I suppose it'd be sturdier if we used your method, but instead of typing out the url, used the API to retrieve it.
<? $url=Loader::helper('navigation'); $canonical=$url->getCollectionURL($c); $canonical=preg_replace("/index.php\?cID=1$/","",$canonical); ?> <link rel="canonical" href="<? echo $canonical; ?>" />
I suppose it'd be sturdier if we used your method, but instead of typing out the url, used the API to retrieve it.
Try this. BASE_URL constant looks like a fair solution..
<?php $canonical = BASE_URL; if ($c->getCollectionId() != 1){ $url=Loader::helper('navigation'); $canonical=$url->getCollectionURL($c); } ?> <link rel="canonical" href="<?php echo $canonical; ?>" />
Thanks this works great.
However, let's say you want trailing slashes and put in the required .htaccess entries.
When visitinghttp://www.example.com/ (or you are redirected to it)
the tag is showing ashttp://www.example.com without the trailing slash.
This adds further confusion for the search bot.
trying if $canonical == the basedomain without trailing slash
then add a trailing slash
However, let's say you want trailing slashes and put in the required .htaccess entries.
When visitinghttp://www.example.com/ (or you are redirected to it)
the tag is showing ashttp://www.example.com without the trailing slash.
This adds further confusion for the search bot.
trying if $canonical == the basedomain without trailing slash
then add a trailing slash
Check this url to get base url and current url in concrete5
http://avenueride.com/how-to-get-concrete5-base-url-or-current-url/...
http://avenueride.com/how-to-get-concrete5-base-url-or-current-url/...