Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonathan Mahoney 2 posts 23 karma points
    Apr 20, 2011 @ 09:24
    Jonathan Mahoney
    0

    Razor Canonical Link Snippet

    Hi

    I'm new the the community so firstly, hello!

    I thought I'd post this l razor snippet that I've put into our site to ensure that every page has a canonical href for search engines, irrespective of how they got there and what magical querystrings were apended along the way.

    Hope its of some use to others (just plonk it in the <head> of your templates):-

    <umbraco:Macro runat="server" language="cshtml">
          @{
             string canonicalHref = "http://www.mydomain.com" + @Model.NiceUrl;         
             <link rel="canonical" href="@canonicalHref" />
            }
     </umbraco:Macro>

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies