[pmwiki-users] Have a canonical url declaration : how to ?
Petko Yotov
5ko at 5ko.fr
Sun Mar 4 15:09:02 CST 2018
Sorry, please use $HTMLHeaderFmt instead of $HTMLFooterFmt as below:
if ($action == 'browse')
$HTMLHeaderFmt['canonical'] = '<link rel="canonical"
href="{$PageUrl}" />';
# optional
else $HTMLHeaderFmt['canonical'] =
'<link rel="canonical" href="{$PageUrl}?action='.$action.'" />';
Petko
On 04/03/2018 22:04, Petko Yotov wrote:
> Add this in config.php to insert a canonical link in the page header:
>
> if ($action == 'browse')
> $HTMLFooterFmt['canonical'] = '<link rel="canonical"
> href="{$PageUrl}" />';
>
> If your wiki is accessible both through HTTP and HTTPS, you should
> select one of those and set correctly the $ScriptUrl variable.
>
> I'm not sure what you mean by 'have such canonical thing if "action"
> pages'.
>
> If you want to set as canonical the base "browse" URL on ?action=edit,
> diff, upload, print and other action pages, remove the first line
> above.
>
> If you want to set the action URL as a canonical URL, add after the
> above lines:
>
>
> else $HTMLFooterFmt['canonical'] =
> '<link rel="canonical" href="{$PageUrl}?action='.$action.'" />';
>
> Note that search engines and bots are usually blocked when they try to
> access ?action=edit and similar pages.
>
> All these canonical urls will not work well for pages where you have
> (:pagelist ... request=1:) or if you use a recipe like HttpVariables
> or MultiLanguage that take information from the URL to display
> different content. (But neither will FastCache.)
>
> Petko
>
> On 04/03/2018 21:13, ABClf wrote:
>> Hello hello,
>>
>> I'm playing with google search console ; there I see I am missing a
>> canonical url.
>>
>> Most of my pages are visible at these different url :
>> http://www.mysite.com/Group/Name
>> http://www.mysite.com/Group.Name
>> http://www.mysite/com/pub/htmlcache/Group.Name.html
>>
>> I believe I need a link rel=canonical somewhere to make different url
>> point to a unique url (avoiding duplicate content) ;
>> what would be the strategy to get it done ? (note : in my special
>> case, most of the pages are saved in cache using fastcache recipe to
>> be served quickly on request).
>> Do I have to write something in template, using Name and Group ? or
>> would a dedicated script in config do better job ?
>>
>> (by the way, perhaps might be good to have such canonical thing if
>> "action" pages).
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
More information about the pmwiki-users
mailing list