Pub Pixel Avatar Image

HTML5 Snippets - Tell Search Engines The Preferred URL For Your Web Page

Published:

Rate Article (Sign in and be the first to rate this article.)

Article Details

Views: 1027

First Published:

Word Count: 672

Edition: 1

Lets say you have a web page that can be accessed by multiple URLs that are all different. For example, lets say your home page can be reached by each of the following URLs listed below.

  • http://www.example.com/
  • http://www.example.com/index.html
  • http://www.example.com/index.htm
  • http://example.com/
  • http://example.com/index.html
  • http://example.com/index.htm
  • http:/www.example.com/
  • http:/www.example.com/index.html
  • http:/www.example.com/index.htm
  • http:/example.com/
  • http:/example.com/index.html
  • http:/example.com/index.htm
  • https://example.com/
  • https://www.example.com/

Search engines will consider each of the URLs in the list above as a different web page with the same content, which will result in duplicate content issues with the search engines. Even though all of the URLs in the list above will take you to the same web page, which is the web sites home page. For this very reason it's best if you choose one URL that search engines can index for your web page. In-order to tell search engines which URL for your web page you would prefer to be indexed. You will need to include the <link> element along with rel attribute and href attribute.

Now the <link> element will define the relationship between the web page the <link> element is placed in to the web page the <link> element links to. You will then need to include the canonical value for the rel attribute in-order to define the relationship between the current web page and the preferred linked web page. Next you will need to add the href attribute. The href attributes value should be the canonical URL for your web page. A canonical URL is basically the preferred URL that you want your users and search engines to see for the link to your web pages content when you have multiple URLs that are all different pointing to the same web page.

It's important to remember that you will need to place the <link> element within the <head> element of the web page in-order for your <link> element to work properly.

Now let me first show you the code by itself for the HTML snippet for telling search engines the preferred URL for your web page using the <link> element. And then I will show you how to code and where to place the HTML snippet for both HTML5 and XHTML5.

Here is the HTML code snippet below to tell search engines the preferred URL for your web page using the <link> element.


<link rel="canonical" href="http://www.example.com/the-preferred-url-for-your-web-page.htm" />

Here is the HTML code snippet to tell search engines the preferred URL for your web page using the <link> element for HTML5 in the example below.


<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Welcome To HTML5</title>
 <link rel="canonical" href="http://example.com/canonical-link.htm">  
</head>
<body>
  
 <p>Search engines should now know the preferred URL for your web page that you want indexed.</p>  

</body>
</html>

And here is the HTML code snippet to tell search engines the preferred URL for your web page using the <link> element for XHTML5 in the example below.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
<head>
 <meta charset="UTF-8" />
 <title>Welcome To XHTML5</title>
 <link rel="canonical" href="http://example.com/canonical-link.htm" />  
</head>
<body>

 <p>Search engines should now know the preferred URL for your web page that you want indexed.</p>  

</body>
</html>

Article Tags

Tag Article (Sign in if you want to tag this article.)

Share This Article

Send To Facebook Link

Tweet This Link

Send To LinkedIn Link

Send To StumbleUpon Link

Digg This Link

Send To Google Plus One Share Link

Send To Reddit Link

Send To Tumblr Link

Send To Delicious Link

Send To FriendFeed Link

Send To Diigo Link

Email Link

AddThis Link

0 Comments

Leave Comment (Sign in and be the first to comment on this article.)

Important

This site cannot guarantee the accuracy of articles, comments, answers and other types of content or media submitted by members or anonymous users and guests, and we recommend that you use common sense when following any advice or information found on this site. Read our full Content Disclaimer Agreement for further information.