Aniela Posted September 9, 2014 Share Posted September 9, 2014 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! 1 Link to comment Share on other sites More sharing options...
radus Posted September 20, 2014 Share Posted September 20, 2014 (edited) 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 September 20, 2014 by radus (see edit history) 1 Link to comment Share on other sites More sharing options...
the.rampage.rado Posted September 24, 2014 Share Posted September 24, 2014 @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 More sharing options...
radus Posted September 24, 2014 Share Posted September 24, 2014 put în header.tpl. Check my homepage www.winerepublic.ro if în doubt. Best of luck. Link to comment Share on other sites More sharing options...
webconcept76 Posted March 20, 2015 Share Posted March 20, 2015 (edited) 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 March 20, 2015 by webconcept76 (see edit history) Link to comment Share on other sites More sharing options...
[email protected] Posted March 20, 2015 Share Posted March 20, 2015 Sorry for jumping in. I would like to add canonical tags to my subcategories so they points at the main category. Where do i put the tag? In header.tpl? Link to comment Share on other sites More sharing options...
anasbmd Posted May 15, 2017 Share Posted May 15, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now