moziloCMS Supportforum

Allgemeines => In English, please! => Thema gestartet von: irrelevant am 11. Januar 2011, 21:54:25

Titel: Canonical Links
Beitrag von: irrelevant am 11. Januar 2011, 21:54:25
regarding http://googlewebmastercentral.blogspot. ... nical.html (http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html)

Mods to 1.11.2 to support this:

In index.php
within    function readTemplate() {
after global $CAT_REQUEST;add global $PAGE_REQUEST;
after    $HTML = preg_replace('/{LAYOUT_DIR}/', $LAYOUT_DIR, $HTML);add $restp = "?cat=" . $CAT_REQUEST . "&page=" . $PAGE_REQUEST;
$HTML = preg_replace('/{CANONICAL_LINK}/', $_SERVER['PHP_SELF'] . $restp, $HTML);

If you use custom parameters in the URL, as I do, and need to include these, you can add something like this between those two lines: foreach ($_GET as $key => $value) {
if (stripos("zoom|goto", $key) !== FALSE) {
$restp .= "&" . $key . "=" . $value;
}
}
where zoom|goto is a list of tags that also need to be included.  Or, just specify them all with suitable defaults if they are not already defined - it depends what you are up to!

You will also need to adjust your template.html file for whatever layouts you use.  Just add    <link rel="canonical" href="{CANONICAL_LINK}" />in the header, under any other <link> tags in there.


This ensures that your pages only appear once in Google search results, and all popularity scores etc are amalgamated across the various forms that the url can take, e.g.:

http://www.example.com/ (http://www.example.com/)
http://www.example.com/index.php (http://www.example.com/index.php)
http://www.example.com/index.php?cat=10_Hello (http://www.example.com/index.php?cat=10_Hello)
http://www.example.com/index.php?cat=10 ... 10_Welcome (http://www.example.com/index.php?cat=10_Hello&page=10_Welcome)

are all treated as the same page.

HTH.
Rob.
Titel: Re: Canonical Links
Beitrag von: azett am 23. Januar 2011, 01:27:01
Hi Rob,
this is great, thank you for sharing it with us. [ticket=97:bcix4ba8]I put it on the feature list for version 1.13[/ticket:bcix4ba8] - maybe it will implemented even in 1.12.