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 :

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

In the forum pages :

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

In the topic pages :

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

For global threads* :

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

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 :

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

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 :

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

In-line Find :

? ''

Replace with :

? "f=Y&amp;"

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

17 Comments

  1. Karate_BKC says:

    Dear sir,
    I would like to try to download your conical url module. expected, this module can work fine at our site forum.
    Thanks sir,
    Karate BKC Indonesia

  2. Ellimist says:

    Your forum apparently runs on SMF. :)

  3. Emir says:

    Hi!

    Is it OK to use this mode in combination with a robots.txt (http://techtitbits.com/2008/07/prevent-duplicate-indexing-of-phpbb3-threads-by-google/)?

    Best regards,
    Emir

    1. Ellimist says:

      Yes, you can use both of them in tandem. But if you use canonical URL tags, you really need not use those robots.txt directives. It’s up to you.

      1. Emir says:

        Thank you.

  4. Hello,

    your theme at phpbb.com is “locked” for some reason.

    Are you still working on this mod? Can it be used with phpBB 3.0.7 PL1?

    Regards,
    Mike

    1. Ellimist says:

      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. Ellimist says:

      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.

  5. Berk says:

    hi, Ellimist!

    link in browser http://nissan-club.org.ua/viewtopic.php?f=68&t=8451

    link canonical http://nissan-club.org.ua/viewtopic.php?f=68&t=8451

    if you insert canonical link in browser it not will be working

    its normally?

    thank you!

    1. Ellimist says:

      Yes, that is perfectly normal. When “&” is parsed by the browser, it turns to ‘&’ only.

  6. Berk says:

    after installing this mod, google stopped indexing my forum

    1. Ellimist says:

      Not if you install this mod correctly, no. You may see a temporary decrease in indexing activity, as it does not have to go through all those bogus/duplicate URLs. But it will not cause Google to stop indexing your board.

      Look at the boards that are using these mods :

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

      They are well indexed and crawled regularly by Google.

  7. Berk says:

    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. Ellimist says:

      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”.

  8. Berk says:

    you suggest to wait until Google will index all over again?

    1. Ellimist says:

      Yes. You can do that.

  9. joncooperst says:

    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 .