Add canonical links to phpBB

phpbb-logo-greenIt’s old news that Google and other major search engines have added support for the <link rel="canonical"> tag to help cut down on duplicate indexing of web pages. While plugins for WordPress, Drupal and Magneto E-Commerce have been released, there has been none such modification for phpBB, where it is, arguably, most needed.

phpBB administrators have used various methods to cut down on this duplicate indexing issue, but adding a canonical URL seems to be the most subtly effective way. Google honours this tag very strongly, and upon finding it in a web page, it should only index the canonical page.

In the view of all this, I have put together a mod for phpBB3 to add the canonical links to phpBB board pages. The Canonical URL mod adds these lines to the phpBB pages :

In the index page :

[html]<link rel="canonical" href="http://www.example.com/" />[/html]

In the forum pages :

[html]<link rel="canonical" href="http://www.example.com/viewforum.php?f=1" />[/html]

In the topic pages :

[html]<link rel="canonical" href="http://www.example.com/viewforum.php?f=1&t=1" />[/html]

For global threads* :

[html]<link rel="canonical" href="http://www.example.com/viewforum.php?t=1" />[/html]

phpBB.com support thread :

http://www.phpbb.com/customise/db/mod/canonical_url/support/mod_discussion_canonical_url-t_875

Download modification :

download

Note :

Normally, global threads will have canonical URLs like this :

[html]<link rel="canonical" href="http://www.example.com/viewforum.php?t=1" />[/html]

If you want the global threads to have canonical URLs with an “f=Y” query string, you just need to make a little change to the code. After installing the mod, open viewtopic.php.
Find :

[php] ‘U_CANONICAL’ => generate_board_url() . "/viewtopic.$phpEx?" . (($topic_data[‘topic_type’] == POST_GLOBAL) ? ” : "f=$forum_id&amp;") . "t=$topic_id" . (($start) ? "&amp;start=$start" : ”),[/php]

In-line Find :

[code]? ”[/code]

Replace with :

[php]? "f=Y&amp;"[/php]

Replace ‘Y’ with the forum id of the forum you want your global threads to belong to.

Join the Conversation

17 Comments

    1. I do not know why it was locked. I’ll PM a MOD team member to find out why.

      As for your query, this mod can be used without any problems with phpBB 3.0.7-PL1.

    2. It seems that they have set up a customisation database called Titania, and they have moved all the styles and mods to there. The mod and styles forum have been set to read-only.

      You can get support for this mod here. or by commenting on this post.

  1. 1. I installed this mod with “Prevent duplicate indexing of phpBB3 threads by Google”, that right?

    or “Add canonical links to phpBB” mod its enough?

    2.
    ” 1. Energy.com
    2. PandoZone.com
    3. AnimorphsFanForum.com

    On my board canonical links displayed as well as on those sites, but in google index has fallen almost to zero (before installing it 3500)

    1. It hasn’t fallen to zero.

      Look, previously, all the duplicate URLs were indexed by Google. So the number of pages indexed were wrongly inflated. Now that Google only indexes one URL for each post/forum, the number of URLs indexed by Google naturally will decrease. This is normal and will eventually lead to an increase in your search engine rank.

      I checked your site and it is in good standing with Google. Your homepage is crawled very frequently. It showed me, “Crawled 3 hours ago”.

  2. Je cherchais ce forum merveilleux, et il a trouvĂ© . Maintenant, je suis votre nom d’utilisateur rĂ©gulier.rnMerci pour l’administration de ce forum .

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.