Re: link rel="canonical"

Discussion forum for MOD Writers regarding MOD Development.
Locked
whaturmuva
Registered User
Posts: 99
Joined: Thu Jun 19, 2008 3:09 pm
Contact:

Re: link rel="canonical"

Post by whaturmuva »

Paul.J.Murphy wrote:A suggestion for a simple enhancement to improve crawler/bot friendliness, based on:
http://googlewebmastercentral.blogspot. ... nical.html

Add just after the <title>...</title> in styles/prosilver/template/overall_header.html:

Code: Select all

<!-- IF U_CANONICAL --><link rel="canonical" href="{U_CANONICAL}" /><!-- ENDIF -->
Add to assign_vars() in index.php:

Code: Select all

'U_CANONICAL' => "{$phpbb_root_path}index.$phpEx",
Add to assign_vars() in viewforum.php:

Code: Select all

'U_CANONICAL' => "{$phpbb_root_path}viewforum.$phpEx?f=$forum_id" . (($start) ? "&start=$start" : ''),
Add to assign_vars() in viewtopic.php:

Code: Select all

'U_CANONICAL' => "{$phpbb_root_path}viewtopic.$phpEx?" . (($topic_data['topic_type'] == POST_GLOBAL) ? '' : "f=$forum_id&") . "t=$topic_id" . (($start) ? "&start=$start" : ''),
I'd also suggest changing the construction of U_VIEW_FORUM and U_VIEW_TOPIC to similarly only include non-zero start parameters, i.e.:

Code: Select all

(($start) ? "&start=$start" : ''))

This should help to eliminate duplicates in search results, improve bot efficiency, and generally have no downsides that I can see. It should have zero impact on board users.

Edit 29 Oct: Updated viewtopic URL to exclude forum_id for globals.

I'm sorry for the blurb here, it comes from area51.phpbb but I received no response as it's not for support purposes. But I had a question regarding this code.

I currently have google indexing my site in two ways. Using my host url: mysite.hosturl.com, and my url: mysite.com

I was wondering if the {$phpbb_root_path} part of this code, could be set as mysite.com. So that when the bots are indexing it as mysite.hosturl.com, the meta tag would encourage it to come in on mysite.com instead of using the hosts domain.

I've been looking for something to do this for awhile (as due to server limitations I can't do a proper 301 redirect)... and this might just be perfect.

So for instance, would it be ok to instead of using

Code: Select all

'U_CANONICAL' => "{$phpbb_root_path}index.$phpEx",
could I instead put the code in as

Code: Select all

'U_CANONICAL' => "http://mysite.com/index.$phpEx",
?

Thanks for the help :)
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: link rel="canonical"

Post by Ather »

CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
whaturmuva
Registered User
Posts: 99
Joined: Thu Jun 19, 2008 3:09 pm
Contact:

Re: link rel="canonical"

Post by whaturmuva »

Thanks Ather for taking the time to respond, but that does not answer my question. To put it simply, instead of using "{$phpbb_root_path}", could I instead use the direct link to my site as described in the quoted portion below.
whaturmuva wrote: So for instance, would it be ok to instead of using

Code: Select all

'U_CANONICAL' => "{$phpbb_root_path}index.$phpEx",
could I instead put the code in as

Code: Select all

'U_CANONICAL' => "http://mysite.com/index.$phpEx",
whaturmuva
Registered User
Posts: 99
Joined: Thu Jun 19, 2008 3:09 pm
Contact:

Re: link rel="canonical"

Post by whaturmuva »

Sorry for the bump, but does anyone know the answer to my question?
Oleg
Former Team Member
Posts: 1221
Joined: Sat Jan 30, 2010 4:42 pm
Location: NYC
Contact:

Re: link rel="canonical"

Post by Oleg »

Have you tried doing it to see what would happen?
Participate in phpBB development: Get involved | Issue tracker | Report a bug | Development board | [url=irc://chat.freenode.net/phpbb-dev]Development IRC chat[/url]
My stuff: mindlinkgame.com
whaturmuva
Registered User
Posts: 99
Joined: Thu Jun 19, 2008 3:09 pm
Contact:

Re: link rel="canonical"

Post by whaturmuva »

nn- wrote:Have you tried doing it to see what would happen?
No, but only because I do not want to ruin my already good google SERP.

I was hoping someone could tell me if I could insert the actual link of the site instead of the {$phpbb_root_path}
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm
Contact:

Re: link rel="canonical"

Post by soumik »

Yes, you can do that without any problems.
Powered by chocolate
Locked

Return to “[3.0.x] MOD Writers Discussion”