Adding A Canonical Tag To An ASP.NET page

A canonical tag is an important tag to add to a web page where you may have duplicate content.

share on facebook share on twitter share on google share on digg share on linked in share on stumble upon

A canonical tag is an important tag to add to a web page where you may have duplicate content. By setting a canonical tag you are telling a search engine what is your preferred page.

You may also have seperate pages that have the same content, this is fine but you should really use a canonical tag to tell them which is the preferred page for indexing. This doesn't mean they will of course but all the major search engines recognise and respect this tag.

So if you have this scenario:

www.yourwebsite.co.uk/fish-bites
www.yourwebsite.co.uk/product.aspx?id=1234

You probably want to have some kind of URL rewriting on but that is another post for another time. This is likely to. You would likely add a canonical tag to this page.

This tag goes into the head of the document and tell the search engine what your preferred page for indexing is.

Using ASP.NET Master Pages
This is also quite straight forward, you do not have access to the head of the document as this resides in the Master. We suggest you had this to the page itself

Dim canonicalTag As New HtmlLink()
canonicalTag.Href = "http://www.yourwebsite.co.uk/fish-bites"
canonicalTag.Attributes("rel") = "canonical"
Page.Header.Controls.Add(canonicalTag)

If you have a better way of doing this let us know.

Here is a video from Google about canonical tags and their benefits and usage:

We are steadily building up our list of useful resource, you can see these in our blog or by going straight to our coding area.

Pebble are specialists when it comes to ASP.NET development. For more information call us on 01733 367799 or email us via our contact page.

Adding A Canonical Tag To An ASP.NET page

Posted in Coding by on 10 January 2014

Related Posts

What Are CSS Shapes?
WHAT ARE CSS SHAPES?
Erm...What is CAPTCHA?
ERM...WHAT IS CAPTCHA?
How To Create A Link To A Phone Number In HTML
HOW TO CREATE A LINK TO A PHONE NUMBER IN HTML
Special HTML Characters
SPECIAL HTML CHARACTERS
Best Practice - Caching Files Using ASP Dot Net
BEST PRACTICE - CACHING FILES USING ASP DOT NET
What is meta information?
WHAT IS META INFORMATION?

Fresh From Twitter...

Join the conversation on Twitter @pebbleltd
for all the latest news on web design, ecommerce and search engine marketing with one of the leading web design agencies in the uk

  • Pebble (Peterborough)

    26 Tesla Court
    Innovation Way
    Peterborough
    PE2 6FL

    Tel: 01733 902070

    View On Map

  • Pebble (Kings Langley)

    The Old Chapel
    69 Primrose Hill
    Kings Langley
    WD4 8HX

    Tel: 01442 505878

    View On Map

Pebble Ltd is registered in England & Wales: 06257777 and registered for VAT No: 993 3500 06

Pebble Ltd is Data Protection registered ZA122783

Adding A Canonical Tag To An ASP.NET page Adding A Canonical Tag To An ASP.NET page A canonical tag is an important tag to add to a web page where you may have duplicate content.

A canonical tag is an important tag to add to a web page where you may have duplicate content. By setting a canonical tag you are telling a search engine what is your preferred page.

You may also have seperate pages that have the same content, this is fine but you should really use a canonical tag to tell them which is the preferred page for indexing. This doesn't mean they will of course but all the major search engines recognise and respect this tag.

So if you have this scenario:

www.yourwebsite.co.uk/fish-bites
www.yourwebsite.co.uk/product.aspx?id=1234

You probably want to have some kind of URL rewriting on but that is another post for another time. This is likely to. You would likely add a canonical tag to this page.

This tag goes into the head of the document and tell the search engine what your preferred page for indexing is.

Using ASP.NET Master Pages
This is also quite straight forward, you do not have access to the head of the document as this resides in the Master. We suggest you had this to the page itself

Dim canonicalTag As New HtmlLink()
canonicalTag.Href = "http://www.yourwebsite.co.uk/fish-bites"
canonicalTag.Attributes("rel") = "canonical"
Page.Header.Controls.Add(canonicalTag)

If you have a better way of doing this let us know.

Here is a video from Google about canonical tags and their benefits and usage:

We are steadily building up our list of useful resource, you can see these in our blog or by going straight to our coding area.

Pebble are specialists when it comes to ASP.NET development. For more information call us on 01733 367799 or email us via our contact page.

Contact Pebble

  • Pebble Ltd (Peterborough)
    26 Tesla Court
    Innovation Way
    Peterborough
    PE2 6FL
    Tel: 01733 902070
  • Pebble Ltd (Kings Langley)
    The Old Chapel
    69 Primrose Hill
    Kings Langley
    WD4 8HX
    Tel: 01442 505878