Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category Home URL and Canonicalization

Quote Reply
Category Home URL and Canonicalization
How do I change the 'category home' url that is used in the category 'crumb trail' on the category pages

<div class="crumb"><%Links::Utils::format_title($title_loop, separator => $crumb_separator, no_escape_separator => $no_escape_crumb_separator, include_home => 1, link_type => 2)%></div>

By default this shows the website homepage url as http://www.********.com/index.html

I want it to read http://www.******.com

This is in reference to SEO Caononicalization & http://www.mattcutts.com/blog/seo-advice-url-canonicalization/

Thanks
Colin Thompson
Quote Reply
Re: [colintho] Category Home URL and Canonicalization In reply to
You probably need a global for it. Give this a go:

remove_index_html_from_breadcrumb
Code:
sub {
my $loop = $_[0];
my $i = 0;
my @loop;
foreach (@$loop) {
if ($i < 1) {
$i++;
$_->{URL} =~ s/index\.html$//;
push @loop, $_;
} else {
$i++;
push @loop, $_;
}
}
return { title_loop => \@loop }
}

<%remove_index_html_from_breadcrumb($title_loop)%>

...put the above line BEFORE this line:

Code:
<div class="crumb"><%Links::Utils::format_title($title_loop, separator => $crumb_separator, no_escape_separator => $no_escape_crumb_separator, include_home => 1, link_type => 2)%></div>

Untested, but should work :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Dec 15, 2009, 2:52 AM
Quote Reply
Re: [Andy] Category Home URL and Canonicalization In reply to
Andy

thanks - tried but got this error (just above the category crumb trail)

Unable to compile 'remove_index_html_from_breadcrumb': syntax error at (eval 356) line 12, near "++ push"

Also, is this going to remove 'index.html' from all the category links in the crumbtrail?

I was hoping to only remove the 'index.html' from the homepage URL link - to make all thee links to the homepag within my site use www.*****.com

regards

Colin
Colin Thompson
Quote Reply
Re: [colintho] Category Home URL and Canonicalization In reply to
Sorry, had a mistake in the code. Should be fixed now.

Quote:
Also, is this going to remove 'index.html' from all the category links in the crumbtrail?

I was hoping to only remove the 'index.html' from the homepage URL link - to make all thee links to the homepag within my site use www.*****.com

Yup, it will *only* do it for the home one :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category Home URL and Canonicalization In reply to
Andy

great job, many thanks

I will now go through my various category templates to add the html code to call the global for all my categories

Thanks again + have a good xmas

regards

Colin
Colin Thompson
Quote Reply
Re: [colintho] Category Home URL and Canonicalization In reply to
Np, you too :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [colintho] Category Home URL and Canonicalization In reply to
Hm, does it make sense to change this only for home.html?
All my categories are called with http://www.mydomain.com/categeory/index.html
Did you find a way to change it to just http://www.mydomain.com/categeory/
???

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Category Home URL and Canonicalization In reply to
You wanna remove the index.html from all the URLs?

Give this a go:

strip_indexhtml
Code:
sub {
my $tmp = $_[0];
$tmp =~ s/index\.html//sig;
return $tmp;
}

Then call in subcategory.html (for example), with:

Code:
<%strip_indexhtml($URL)%%>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category Home URL and Canonicalization In reply to
Andy wrote:
You wanna remove the index.html from all the URLs?

Give this a go:

strip_indexhtml
Code:
sub {
my $tmp = $_[0];
$tmp =~ s/index\.html//sig;
return $tmp;
}


Then call in subcategory.html (for example), with:

Code:
<%strip_indexhtml($URL)%%>


Cheers

Thanks for your idea, Andy. What do you think could it be changed by .htaccess as well?
I would prefer a change of the .htaccess file :-)

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Category Home URL and Canonicalization In reply to
You mean do a 301 redirect with anything that has a index.html at the end? Shouldn't be too hard:

RewriteRule ^(.*)/index.html http://www.domain.com/$1/ [R=301,L]

Untested, but should do the trick.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category Home URL and Canonicalization In reply to
Andy wrote:
You mean do a 301 redirect with anything that has a index.html at the end? Shouldn't be too hard:

RewriteRule ^(.*)/index.html http://www.domain.com/$1/ [R=301,L]

Untested, but should do the trick.

Cheers

No, I don't think google likes redirects!
I mean changing some of these parts in my .htacess file

Code:
# category page rewrite
RewriteRule ^(.*)/index\.html$ /cgi-bin/unterricht/page.cgi?g=$1/index.html [L]

But the more I think about it. Links like this
http://www.mydomain.com/categeory/index.html
would be still produced by the code and would be spidered by google, even if I change the .htaccess file. Or am I wrong...

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Category Home URL and Canonicalization In reply to
Mmm, using mod_rewrite may have issues if you remove the index.html stuff, as that may confuse the rewrite rules (at least I've had issues with that previously)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category Home URL and Canonicalization In reply to
Andy wrote:
You wanna remove the index.html from all the URLs?

Give this a go:

strip_indexhtml
Code:
sub {
my $tmp = $_[0];
$tmp =~ s/index\.html//sig;
return $tmp;
}


Then call in subcategory.html (for example), with:

Code:
<%strip_indexhtml($URL)%%>


Cheers

The code above works fine. But I just changed it for a few seconds, cause links with urls like
http://www.mydomain.com/categeory/index.html
are still working, too.
I think google would now spider a lot of duplicate urls :-(


PS: The code above did not work on my home.html in this part. It should work, cause subcategory.html is called.
Any suggestions why it does not work???
Code:
<%set split = Links::Utils::column_split($category_loop.length, $home_category_cols)~%>
<div class="clear">
<%loop category_loop%>
<%~set splitmod = $row_num % $split%>
<%~if row_num == 1 or splitmod == 1 or split == 1%><dl><%endif%>
<%~include subcategory.html%>
<%~if row_num == $category_loop.length or splitmod == 0%></dl><%endif%>
<%~endloop%>
</div>

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Category Home URL and Canonicalization In reply to
Quote:
PS: The code above did not work on my home.html in this part. It should work, cause subcategory.html is called.
Any suggestions why it does not work???

Mmm, should work fine - if you've put the code in subcategory.html

Quote:
The code above works fine. But I just changed it for a few seconds, cause links with urls like
http://www.mydomain.com/categeory/index.html
are still working, too.
I think google would now spider a lot of duplicate urls :-(

Thats why you need that rewrite rule I gave - as that will tell google the pages are a 301 ( perminant) redirect:

Code:
RewriteRule ^(.*)/index.html$ http://www.domain.com/$1/ [R=301,L]

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [colintho] Category Home URL and Canonicalization In reply to
If you're using 3.3.0, there's the option to not append index.html on all the index pages.

Adrian
Quote Reply
Re: [brewt] Category Home URL and Canonicalization In reply to
brewt wrote:
If you're using 3.3.0, there's the option to not append index.html on all the index pages.

Hi Adrian,
great, but I'm still waiting for a german translation of 3.3.0 Whistle

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Category Home URL and Canonicalization In reply to
Our German partner hasn't sent us any translations, so we don't have a german release.

Adrian

Last edited by:

brewt: Dec 15, 2009, 12:32 PM
Quote Reply
Re: [brewt] Category Home URL and Canonicalization In reply to
brewt wrote:
Our German partner hasn't sent us any translations, so we don't have a german release.

Yes I know, I'm waiting for half a year now for a german version...
I've contacted Jack already, and he told me, that 3.3.0 has only a few minor changes.

But the option to not append index.html on all the index pages is not a minor change to me. This is what I was waiting for...

So what can I do.
Do I have to live with a german 3.2.0 version for ever???

Matthias
gpaed.de