Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
7.6k views
in Q2A Core by
edited by

Hello! Hope someone has an answer because I am stuck with this issue!

How to add canonical to TAGS? (It's only available for questions)

Thanks!

Q2A version: Last one

1 Answer

+1 vote
by
Add this function in your theme's qa-theme.php file
 
function head_custom() {
qa_html_theme_base::head_custom();
if ($this->template == "tags" || $this->template == "tag") {
$this->output('<link rel="canonical" href="'.qa_opt('site_url').$this->request.'"/>');
//or replace above with whatever URL you want to
}
}
by
Thanks man, that's perfect!
by
Glad, I was of help :-)
by
edited by
Well no sorry (I didn't see), it's not working because the code add "tag" but in my q2a, I add an other word in config.php, and moreover when you have differents words, it didn't add "+"  between words, that made a new canonical url...
by
Well you had not mentioned that earlier, what you can do is replace "tag", "tags" with the new URL keyword that you have specified in your config file. In Q2A, two word tags are separated with a dash (-). I am not getting where you got the +
...