2

Recently we saw many duplicate content hits in our blog and this is not good for SEO

This is due to using aw_blog not adding a canonical tag (actually there has not been any real development - other then urgent security fixes)

Question: How can we add a canonical tag to aw blog?

We were thinking of adding it to _prepareMetaData in Abstract.phtml

protected function _prepareMetaData($meta)
{
    if (is_object($meta)) {
        $head = $this->getLayout()->getBlock('head');
        if ($head) {
            $head->setTitle($meta->getTitle());
            $head->setKeywords($meta->getMetaKeywords());
            $head->setDescription($meta->getMetaDescription());
2

Updating the file app/code/community/AW/Blog/Block/Abstract.php (line 184)

with this code, seems to work

protected function _prepareMetaData($meta)
{
    if (is_object($meta)) {
        $head = $this->getLayout()->getBlock('head');
        if ($head) {
            $head->setTitle($meta->getTitle());
            $head->setKeywords($meta->getMetaKeywords());
            $head->setDescription($meta->getMetaDescription());
            /** CUSTOM CODE SNH 10-jul-2015 **/
            if ($post_identifier = $identifier = $this->getRequest()->getParam('identifier')) {
                $url = $this->getBlogUrl($post_identifier);
                $url = rtrim(strtok($url, '?'),"/");
                $head->addLinkRel('canonical',$url);
            }
        }
    }
}

Using getParam and not an object is not the nicest solution. Any other suggestions?

thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.