Canonical URL

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Extensions Robot
Extensions Robot
Extensions Robot
Posts: 29220
Joined: Sat Aug 16, 2003 7:36 am

Canonical URL

Post by Extensions Robot »

Modification name: Canonical URL
Author: soumik
Modification description: Adds canonical URLs to index, viewtopic and viewforum pages as specified by Google (Specify your canonical - Official Google Webmaster Central Blog).

A <link> tag is added to the <head> section of the page.
Modification version: 1.0.0
Tested on phpBB version: 3.0.6

Download file: canonical_url.zip
File size: 31.17 KiB

Modification overview page: View

The phpBB Team is not responsible nor required to provide support for this modification. By installing this MOD, you acknowledge that the phpBB Support Team or phpBB Extension Customisations Team may not be able to provide support.

-->Modification support<--
Last edited by Extensions Robot on Mon Sep 19, 2022 7:33 pm, edited 12 times in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 18316
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact:

Canonical URL

Post by DavidIQ »

Modification validated/released

Notes:
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm
Contact:

Canonical URL

Post by soumik »

Download latest version : Here

This mod adds <link> tag is added to the <head> section of the page.
  • For the index page :

    Code: Select all

    <link rel="canonical" href="http://www.example.com/" />
  • For forum pages :

    Code: Select all

    <link rel="canonical" href="http://www.example.com/viewforum.php?f=X" />
  • For threads :

    Code: Select all

    <link rel="canonical" href="http://www.example.com/viewtopic.php?f=X&t=Y" />
  • For global threads* :

    Code: Select all

    <link rel="canonical" href="http://www.example.com/viewtopic.php?t=Y" />
Normally, global threads will have canonical URLs like this :

Code: Select all

http://www.example.com/viewtopic.php?t=X
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 :

Code: Select all

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

Code: Select all

''
Replace with :

Code: Select all

"f=Y&"
Replacing 'Y' with the forum id of the forum you want your global threads to belong to.
Last edited by soumik on Tue Dec 01, 2009 1:18 pm, edited 2 times in total.
Powered by chocolate
User avatar
DoYouSpeakWak
Registered User
Posts: 2311
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak
Contact:

Re: Canonical URL

Post by DoYouSpeakWak »

Congrats on the fast validation. This is great mod :)
Whatever you share comes back. Support the phpBB Communities
Offering paid services. 15+ years of experience with phpBB3 and server management.
User avatar
Ahri89
Registered User
Posts: 525
Joined: Sat Apr 07, 2007 2:53 pm
Location: Spain
Contact:

Re: Canonical URL

Post by Ahri89 »

In viewforum.php I found several results of:

Code: Select all

$template->assign_vars(array(
, please help me :P


Thanks for this great mod :D
MODs translated to Spanish: ACP Add User MOD, ACP Announcement Centre, Advertisement Management, Custom Profile Fields, Update Reminder, Flood time setting per forum, MOD Version Check, Posting template, Prune Log, Simple Trash Bin, TinyPic Plugin, User Reminder, View Profile, View your topics, and more...

Sorry for my bad english xD
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm
Contact:

Re: Canonical URL

Post by soumik »

You can add it after any of the results. The effect will be the same.
Powered by chocolate
User avatar
Ahri89
Registered User
Posts: 525
Joined: Sat Apr 07, 2007 2:53 pm
Location: Spain
Contact:

Re: Canonical URL

Post by Ahri89 »

soumik wrote:You can add it after any of the results. The effect will be the same.
Thanks! :)
MODs translated to Spanish: ACP Add User MOD, ACP Announcement Centre, Advertisement Management, Custom Profile Fields, Update Reminder, Flood time setting per forum, MOD Version Check, Posting template, Prune Log, Simple Trash Bin, TinyPic Plugin, User Reminder, View Profile, View your topics, and more...

Sorry for my bad english xD
demon327
Registered User
Posts: 847
Joined: Thu Nov 16, 2006 2:16 pm

Re: Canonical URL

Post by demon327 »

Is there any thing chanded since the last RC? :)
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm
Contact:

Re: Canonical URL

Post by soumik »

No, nothing has been changed as of yet since the last RC. The latest release link is something I did for the future. :)
Powered by chocolate
CaNNon_
Registered User
Posts: 392
Joined: Wed Apr 29, 2009 2:07 am

Re: Canonical URL

Post by CaNNon_ »

very nice! :D
User avatar
alahamdan
Registered User
Posts: 248
Joined: Tue Oct 23, 2007 7:37 am
Contact:

Re: Canonical URL

Post by alahamdan »

Hello and thanks for the Mod

I think its a very important one, but i have a question

For some reason when i search for a topic title in Google, i find that Google index my phpbb forum topics as following:

viewtopic.php?f=1&t=36308

While i noticed your using this format as canonical:

viewtopic.php?t=35035

So if Google preferred this way, why don't we use it in this mode?! or it wont make a big difference?


======

Another Issue is about the amp; thing.

I noticed when you go to a topic, choose page 2 for example, the canonical URL will contain amp; in it, so when u take it, use in browser, it will take you to the first page of the topic, not to page 2.

I went to viewtopic.php and did the following:

Code: Select all

"f=$forum_id&")  removed amp; so it became "f=$forum_id&")
And

Code: Select all

"&start=$start" : '') removed amp; so it became "&start=$start" : '')
Now it wont show amp; and the canonical link is valid, takes you to the right page, so any problem with doing what i did? or its ok?

By the way, im Google webmasters tools, Google report amp; as a parameter asking you if you would like to ignore it, i think Google don't like this parameter!

Thanks again for the mod, its better than playing with the robots.txt :D
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm
Contact:

Re: Canonical URL

Post by soumik »

alahamdan wrote:Hello and thanks for the Mod

I think its a very important one, but i have a question

For some reason when i search for a topic title in Google, i find that Google index my phpbb forum topics as following:

viewtopic.php?f=1&t=36308

While i noticed your using this format as canonical:

viewtopic.php?t=35035

So if Google preferred this way, why don't we use it in this mode?! or it wont make a big difference?
The "f=1" query string is for the board to track the forum the user is visiting. This mod generates canonical URL in the format "viewtopic.php?f=1&t=1". Only in case of global threads, it generates canonical URLs in the form "viewtopic.php?t=1", because global threads are present in every forum and it will be a duplicate indexing issue.
There is even the option of making the canonical URLs of global threads belong to a particular forum.

About the & issue :
'&' is the HTML code for '&'. '&' will get parsed to '&' when read by the browser. The 'amp;' part is not extra. If you have doubts, please see the source code for any page and view the URLs that contain '&'.
Powered by chocolate
User avatar
alahamdan
Registered User
Posts: 248
Joined: Tue Oct 23, 2007 7:37 am
Contact:

Re: Canonical URL

Post by alahamdan »

soumik wrote:
alahamdan wrote:Hello and thanks for the Mod

I think its a very important one, but i have a question

For some reason when i search for a topic title in Google, i find that Google index my phpbb forum topics as following:

viewtopic.php?f=1&t=36308

While i noticed your using this format as canonical:

viewtopic.php?t=35035

So if Google preferred this way, why don't we use it in this mode?! or it wont make a big difference?
The "f=1" query string is for the board to track the forum the user is visiting. This mod generates canonical URL in the format "viewtopic.php?f=1&t=1". Only in case of global threads, it generates canonical URLs in the form "viewtopic.php?t=1", because global threads are present in every forum and it will be a duplicate indexing issue.
There is even the option of making the canonical URLs of global threads belong to a particular forum.

About the & issue :
'&' is the HTML code for '&'. '&' will get parsed to '&' when read by the browser. The 'amp;' part is not extra. If you have doubts, please see the source code for any page and view the URLs that contain '&'.
thanks for your reply.

Yes i agree now about the first part.

But about amp; , the browser do not parse it, i tried it my self, i saw the problem happened with another person too. so i tried removing it from the code, and it now include the link in away when u take and paste in browser it works fine!

So removing it as i mentioned above may cause a problem? or its fine?

And thanks again for the important mode.
Peter77sx
Registered User
Posts: 3260
Joined: Wed Nov 09, 2005 2:51 pm

Re: Canonical URL

Post by Peter77sx »

If you type it into an URL of course it's not going to work. I also had a little doubt myself, but after reading a bit more on Google related subjets, I think search engines are smart enough to figure it out.

Look at the Bullet next to the topic title of this thread and then view the page source. you'll see &bull; :) .
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm
Contact:

Re: Canonical URL

Post by soumik »

As Peter77sx rightly said, ASCII special characters like ©, @ and & will be present in the source as '&copy;', '&#64;' and '&' respectively. See : http://www.yellowpipe.com/yis/tools/ASC ... /index.php
Powered by chocolate
Locked

Return to “[3.0.x] MOD Database Releases”