You are browsing the archive for
"web development"

How And When You Should Use Canonical URLs For Better SEO

April 12th, 2015

Too often ignored or misused, canonical URLs represent a key factor to improve your websites’s SEO and they are actually a very simple technique to understand and deploy.

Basically, canonical URLs tell Google (and other search engines) which is the preferred URL they should index when the same content is served through multiple URLs. This is a very common issue on dynamic websites or online stores. Look at the following examples:

EXAMPLE #1:

http://www.example.com/content.html
http://example.com/content.html

Your server is configured to offer the same content with or without the “www.” subdomain (this is super-common). Generally, it is suggested to use the complete version (with “www.”) as the canonical URL.

EXAMPLE #2:

http://www.example.com/content.html
https://www.example.com/content.html

Your server is configured to offer the same content on HTTPS protocol (for example when the user is logged in). Google suggest to set the HTTPS version as the canonical URL.

EXAMPLE #3:

http://www.example.com/
http://www.example.com/index.html

Your server is configured to offer your default home page with or without its file name. You should use the domain-only version (without file name) as the canonical URL.

EXAMPLE #4:

http://www.example.com/category/post-name
http://www.example.com/category/post-name/

Your server is configured to offer the same content with or without the trailing slash. It’ usually suggested to use the version with trailing slash as the canonical URL.

EXAMPLE #5:

http://www.example.com/dresses/long-red-dress.html
http://www.example.com/dresses/red/long-red-dress.html
http://www.example.com/dresses/long/long-red-dress.html

Dued to dynamic URLs, the same page is reached through different URLs as a result of category browsing.

EXAMPLE #6:

http://www.example.com/cat.php?p=dress&c=red&t=long
http://www.example.com/cat.php?p=dress&t=long&c=red
http://www.example.com/dresses/red/long/

Dued to dynamic URLs, the same product category can be reached through different URLs (e.g., depending on different querystring parameters).

All the above examples would greatly enjoy a correct use of canonical URLs in order to:

  • Consolidate duplicate or similar content on search engines
  • Consolidate tracking metrics for a single product, article or category served through different URLs
  • Defining the URL you want people to see

How To Setup The Canonical URL Attribute

Now, take the example #1 above and suppose you want to set http://www.example.com/content.html to be the prefered URL. The easiest and most effective method to do this is including the following line into the <head> section of that page:

<link rel="canonical" href="http://www.example.com/content.html" />

It’s just that simple. Rememeber to always use absolute paths and not relative paths when declaring canonical URLs. The following line, for example, is wrong:

<link rel="canonical" href="/content.html" />

jQuery.RandomBlinker: The Plugin For Useless Random Animations

January 26th, 2015

A couple of years ago I created a nice jQuery-powered random animation for a web design project I was working on.

I recently found some time to recover that work and I thought it could be easily customized for other projects, too. So I cleaned up the original code and I trasformed it into an easy-to-use jQuery plugin.

jQuery.RandomBlinker

The effect principle is actually very easy to understand and customize: a full width table is created in the target container and its cells are randomically turned on and off at a given interval.

Go to the official jQuery.RandomBlinker page to see a working demo, read the full story, get usage instructions and download links!