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

I would like to know i can i add the canonicalization tag in a similar fashion proposed in this question:

http://www.question2answer.org/qa/2844/how-to-add-canonicalization-with-absolute-url

In particular i would like to know how can i find if the current page is a category since the if ($this->template=='question') { .... } trick listed in the abover question can't be applied in this case because the template value in case of categories is 'qa' (that seems to be a template used also for other page types).

Plus i would like to know how can i retrieve codewise the canonical urls for categories since i have the following canonicalization problem:

Google has crawled (and detected as duplicate version) three url versions of the same category page:

http://[MYWEBSITE]/qa/categoryname

http://[MYWEBSITE]/qa/Categoryname (capital 'C')

http://[MYWEBSITE]/qa/qa/categoryname

by
While i don't have solved this problem (i can't find a way to retrieve canonical urls inside the code for categories without having to query the database) i have found a workaround for the moment that can answer at the same time this question "How can i add robots metatag to all the pages but questions and user profiles?"

You can override inside qa-theme.php the head_links function with this one:

function head_links(){
    if($this->template !== 'question' && $this->template !== 'user'){
         if(($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']) != substr(qa_opt('site_url'), strpos(qa_opt('site_url'), '://') + 3)){
            $this->output('<meta name="ROBOTS" content="noindex, follow"/>');
        }
    }
}

This function add the "noindex, follow" parameters to all pages but question and user profiles (those that are content pages basicaly) allowing Google to not index "archive" pages (that are often considered low value content) while still processing the link juice passed by these pages to question and user profile pages.

The noindex pages will not be included in the search engine index and they will not trigger any duplicate content filter.

NOTE: the code is experimental and has not been tested exstensively; use it at YOUR OWN RISK

Please log in or register to answer this question.

...