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

Google don't like canonical links, it's a burden. And if you pay attention to search business, Google recently has some problems with canonical indexing.

Q2A register and login links does not have rel=nofollow tags, and Q2A developers underestimate this because whenever you browse a Q2A question page, a tag page, a category page, a user profile page, there is a bunch of dofollow canonical links.

Thou we can disallow /register /login in robots.txt, it's still good to add rel=nofollow tags in the first place.

The coding style of Q2A core is hard to add such a small trick.

Recently I have a new Q2A installation. Not many questions, but a horde of excluded pages because of register/login links.

When you have >1000 excluded canonical links, you will understand the matter. Much more painful if the number is 9.6k

1 Answer

0 votes
by

Override this:

    public function nav_link($navlink, $class)
    {
         
        $navurl= $navlink['url'];
       
        if (strpos($navurl, "?to=") !== false) {
            $rel = 'rel="nofollow"';
        }
       
        if (isset($navlink['url'])) {
            $this->output(
                '<a '.$rel.' href="' . $navlink['url'] . '" class="qa-' . $class . '-link' .
                (@$navlink['selected'] ? (' qa-' . $class . '-selected') : '') .
                (@$navlink['favorited'] ? (' qa-' . $class . '-favorited') : '') .
                '"' . (strlen(@$navlink['popup']) ? (' title="' . $navlink['popup'] . '"') : '') .
                (isset($navlink['target']) ? (' target="' . $navlink['target'] . '"') : '') . '>' . $navlink['label'] .
                '</a>'
            );
        } else {
            $this->output(
                '<span class="qa-' . $class . '-nolink' . (@$navlink['selected'] ? (' qa-' . $class . '-selected') : '') .
                (@$navlink['favorited'] ? (' qa-' . $class . '-favorited') : '') . '"' .
                (strlen(@$navlink['popup']) ? (' title="' . $navlink['popup'] . '"') : '') .
                '>' . $navlink['label'] . '</span>'
            );
        }

        if (strlen(@$navlink['note']))
            $this->output('<span class="qa-' . $class . '-note">' . $navlink['note'] . '</span>');
    }
 

...