Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
576 views
in Q2A Core by

At the moment im using this in my advanced theme to get the canonicalization:

function head_custom()
{
qa_html_theme_base::head_custom();
$this->output( '<link rel="canonical" href="'.@$this->content['q_view']['url'].'" />' );
}

The output in HTML is something like

<link rel="canonical" href="../1234/this-is-my-question-title" >

How can i change this to get an absolute url? like:

<link rel="canonical" href="http://www.question2answer.org/qa/1234/this-is-my-question-title" >

1 Answer

0 votes
by

Try using this inside head_custom, after you called the default one:

if ($this->template=='question') {

global $qa_db;
$raw=$this->content['q_view']['raw'];
$canonical=qa_path_html(qa_q_request($raw['postid'], $raw['title']), null, qa_get_option($qa_db, 'site_url'));
$this->output( '<link rel="canonical" href="'.$canonical.'" />' );

}
by
Suggestion for 1.3: include this in the default template, it's a very useful directive for SEO :)
...