Help to make canonical for staticpages, please
Help to make canonical for staticpages, please
Help to make canonical for staticpages, please. This is important for website optimization. Here is the main page of the series of articles on my website https://webshef.ru/pages/sistemi-pitaniya.html . It is made static and links are also to static pages. But there is no canonical anywhere and I can't find an opportunity to do this. A page without canonical on the internet today will not be evaluated by a search engine.
Re: Help to make canonical for staticpages, please
Thankfully, this is not true. Google for example will certainly index pages without a canonical - as that's only needed to avoid issues with duplicated content.
But that does not mean it would not be better to set it if the necessary data are available. For regular entries, the theme will do that work - see https://github.com/s9y/Serendipity/blob ... pl#L17-L22 as an example. But I have never added it to static pages. Would editing such a .tpl file be possible for you if we can present the extended code here? Are you certain you really need that feature?
But that does not mean it would not be better to set it if the necessary data are available. For regular entries, the theme will do that work - see https://github.com/s9y/Serendipity/blob ... pl#L17-L22 as an example. But I have never added it to static pages. Would editing such a .tpl file be possible for you if we can present the extended code here? Are you certain you really need that feature?
Re: Help to make canonical for staticpages, please
With regular entryes everything is fine! It is necessary for static pages. Of course of course of course!!!! Need a code! Yes, I will work with tpl. A thousand thanks for the intention to help!))))onli wrote: ↑Wed Jan 19, 2022 4:17 pm Thankfully, this is not true. Google for example will certainly index pages without a canonical - as that's only needed to avoid issues with duplicated content.
But that does not mean it would not be better to set it if the necessary data are available. For regular entries, the theme will do that work - see https://github.com/s9y/Serendipity/blob ... pl#L17-L22 as an example. But I have never added it to static pages. Would editing such a .tpl file be possible for you if we can present the extended code here? Are you certain you really need that feature?
Re: Help to make canonical for staticpages, please
Okay, I have one approach you could try.
In the index.tpl of your theme (you can use the template editor plugin to edit it, it will also create a fork and thus make the change update proof) there should be these lines:
Change them to this:
Actually, since there is no canonical on your static page so far it's possible the canonical is set different in your theme. In that case just add this part somewhere in the head section of the index.tpl:
This should add the canonical as a relative url. Strange to me, but I checked and search engines are supposed to be fine with that. You might want to check that with an analysis tool, if a canonical appears with this change. But creating the real absolute url at that point would be a bit hard.
In the index.tpl of your theme (you can use the template editor plugin to edit it, it will also create a fork and thus make the change update proof) there should be these lines:
Code: Select all
{if ($view == "start")}
<link rel="canonical" href="{$serendipityBaseURL}">
{/if}
Code: Select all
{if ($view == "start") && ! isset($staticpage_permalink)}
<link rel="canonical" href="{$serendipityBaseURL}">
{/if}
{if ($view == "start") && isset($staticpage_permalink)}
<link rel="canonical" href="{$staticpage_permalink}">
{/if}
{if ($view == "plugin") && isset($staticpage_permalink)}
<link rel="canonical" href="{$staticpage_permalink}">
{/if}
Code: Select all
{if ($view == "start") && isset($staticpage_permalink)}
<link rel="canonical" href="{$staticpage_permalink}">
{/if}
{if ($view == "plugin") && isset($staticpage_permalink)}
<link rel="canonical" href="{$staticpage_permalink}">
{/if}
Re: Help to make canonical for staticpages, please
Great! Thanks! It works! The first option worked right away!!:-) Now static pages have become canonical! Hurray!onli wrote: ↑Sun Jan 23, 2022 12:19 pm Okay, I have one approach you could try.
In the index.tpl of your theme (you can use the template editor plugin to edit it, it will also create a fork and thus make the change update proof) there should be these lines:
Change them to this:Code: Select all
{if ($view == "start")} <link rel="canonical" href="{$serendipityBaseURL}"> {/if}
Code: Select all
{if ($view == "start") && ! isset($staticpage_permalink)} <link rel="canonical" href="{$serendipityBaseURL}"> {/if} {if ($view == "start") && isset($staticpage_permalink)} <link rel="canonical" href="{$staticpage_permalink}"> {/if} {if ($view == "plugin") && isset($staticpage_permalink)} <link rel="canonical" href="{$staticpage_permalink}"> {/if}