nicoknoll/MarkupSEO

Does canonical require "link rel=" format instead of "meta"?

Opened this issue · 1 comments

I was not getting the "meta name=canonical" tag to be recognized by a popular SEO extension I use, so I located the part of the MarkupSEO module that emits and made a simple change around line 340 in MarkupSEO.module:

    // add "render"
    $rendered = '';
    foreach($pageData as $name => $content) {
        if($name == 'custom') { 
            continue; 
        }
        if($name == 'title') {
            if($this->titleFormat == '') continue;
            $rendered .= '<title>'.$this->parseTitle($page, $content).'</title>'.PHP_EOL; 
            continue;
        }
        if($name == 'canonical') {
            $rendered .= '<link rel="canonical" href="'.$content.'">'.PHP_EOL; 
            continue;
        }
        $rendered .= '<meta name="'.$name.'" content="'.$content.'">'.PHP_EOL;
    }

Now the canonical reference is correctly recognized by the SEO checker I was using.

Looks good to me. I'll implement it in the next release.