URLs in Catalyst Apps
Google along with many other search engines has a habit of treating URLs differently if they end with a trailing-slash or not. How much this actually harms your SEO is questionable, but I prefer things consistent.
The following URLs are seen as completely different:
http://www.myselfequalsshift.com/blog/urls-in-catalyst-apps http://www.myselfequalsshift.com/blog/urls-in-catalyst-apps/
Most of the time these 2 requests will result in the same place, and Google will see duplicate content.
To protect against this, override the following methods in MyApp.pm...
sub uri_for { my $c = shift; my $uri = $c->next::method( @_ ); $uri->path( $uri->path . '/' ) if $uri->path !~ m:/$:; return $uri; } sub uri_for_action { my $c = shift; my $uri = $c->next::method( @_ ); $uri->path( $uri->path . '/' ) if $uri->path !~ m:/$:; return $uri; }
Hostless or Relative URLs
By default Catalyst will create fully qualified URLs which I'm not overly keen on, so to enable hostless, or even relative URLs, list SmartURI in your MyApp.pm plugins...
use Catalyst qw/ ... SmartURI ... /;
And modify your config:
<Plugin::SmartURI> disposition host-header uri_class URI::SmartURI </Plugin::SmartURI>
Now in your templates:
<a href="[% c.uri_for_action( '/mycontroller/myaction' ).hostless %]">some link</a>