Add canonical links to phpBB

It’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 :


In the forum pages :


In the topic pages :


For global threads* :

[html][/html] support thread :

Download modification :

Note :

Normally, global threads will have canonical URLs like this :


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&”) . “t=$topic_id” . (($start) ? “&start=$start” : ”),[/php]

In-line Find :

[code]? ”[/code]

Replace with :

[php]? “f=Y&”[/php]

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