Jump to content

Canonical rel prev/next noindex 1.6


Aniela

Recommended Posts

Hello,
 
I just added the canonical tag to my page and it works fine. Then I added the re prev/next with this code:


 {if $start!=$stop}
{if $p != 1}
{assign var='p_previous' value=$p-1}
<link rel="prev" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}/{$link->goPage($requestPage, $p_previous)}" />
  {else}

{/if}
{if $pages_nb > 1 AND $p != $pages_nb}
{assign var='p_next' value=$p+1}
<link rel="next" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}/{$link->goPage($requestPage, $p_next)}" />
{else}

{/if}
{/if}

Which unfortunately doesn't work for subcategories, it returns the main category instead. Any ideas what to add or change?

 

Then I also need the pages 2,3, etc. to be noindex, follow. What I can I change there?

 

I also added everything in the head.tpl and I use version 1.6.0.7 with the default bootstrap theme.

 

Thank you so much in advance!

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I use this one and works just fine 

 

<!-- Link rel canonical -->  // works on 1.5.6.2
 
 {if $page_name == index}
<link rel="canonical" href="{$base_dir}" />
{elseif $page_name == product}
<link rel="canonical" href="{$request_uri}" />
{elseif $page_name == category}
<link rel="canonical" href="{$request_uri}" />
{else}
<link rel="canonical" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}/" />
{/if}
 
<!-- /Link rel canonical -->
Edited by radus (see edit history)
  • Like 1
Link to comment
Share on other sites

@radus where I should place this code because I have tons of metadata and titles duplicated in google webmaster tools like:

 

/en/82-gilbert-xact-headguard.html
/en/rugby-headguards/82-gilbert-xact-headguard.html

 

 

When I click on the first page it redirects me to the second and I can't end up with the first url in the toolbar. But obviously Google sees it as duplicate content in WT which is annoying because I did some nice job eliminating the real duplicates and now that.

Link to comment
Share on other sites

  • 5 months later...
Pour ceux sous 1.6 avec URl rewriting d'activer , et qui besoin de supprimer les paramètre d'url p= et n= récupérer dans la balise canonical des catégories :
 
 
(attention j'utilise la même fonction regex_replace que le else
à la différence qu'il faut enlever le  / à fin )
 
 
Le code Ok :
<!-- Link rel canonical  --> 

 {if $page_name == index}
<link rel="canonical" href="{$base_dir}" />

{elseif $page_name == product}
<link rel="canonical" href="{$request_uri}" />

{elseif $page_name == category}
<link rel="canonical" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}" />

{/if}
<!-- /Link rel canonical -->

ps: je dé-conseil l'utilisation du dernier else qui peux poser des problèmes 

 

{else}
<link rel="canonical" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}" />

Edited by webconcept76 (see edit history)
Link to comment
Share on other sites

  • 2 years later...

Hello,

 

I just added the canonical tag to my page and it works fine. Then I added the re prev/next with this code:


 {if $start!=$stop}
{if $p != 1}
{assign var='p_previous' value=$p-1}
<link rel="prev" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}/{$link->goPage($requestPage, $p_previous)}" />
  {else}

{/if}
{if $pages_nb > 1 AND $p != $pages_nb}
{assign var='p_next' value=$p+1}
<link rel="next" href="/{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}/{$link->goPage($requestPage, $p_next)}" />
{else}

{/if}
{/if}

Which unfortunately doesn't work for subcategories, it returns the main category instead. Any ideas what to add or change?

 

Then I also need the pages 2,3, etc. to be noindex, follow. What I can I change there?

 

I also added everything in the head.tpl and I use version 1.6.0.7 with the default bootstrap theme.

 

Thank you so much in advance!

I'm having this exact issue with my website, i also have the canonical tag as well as the rel prev/next tag that are working fine but on subcategories they're pointing to the root category...and also need the /?p=2,3,4 pages to be no index, we're on the exact same boat.

 

If you've found a solution to this, It would be greatly appreciated if you share it Aniela, I know this thread is almost 3 years old but it's the only one i found explaining the exact same issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...