Search code examples
wordpressseotumblrcanonical-link

Should I set a default canonical link sitewide or Is possible to set a custom canonical link automatically in Tumblr?


Unfortunately, there's no way (that I know of - I tried below) for me to set a canonical link per Tumblr post so I was thinking of setting the canonical link (sitewide on the Tumblr) to my WordPress homepage - good idea or bad?

I added a content source link to the post and tried adding this to my tumblr theme but none worked, the link would come out blank...

{block:PermalinkPage}
{block:Posts}
{block:ContentSource} 
<link rel='canonical' href='{SourceURL}'>
{/block:ContentSource}
{/block:Posts}
{/block:PermalinkPage}

{block:PermalinkPage}
<link rel='canonical' href='{SourceURL}'>
{/block:PermalinkPage}

{block:PermalinkPage}
{block:ContentSource} 
<link rel='canonical' href='{SourceURL}'>
{/block:ContentSource}
{/block:PermalinkPage}

All help is appreciated, thanks in advance.


Solution

  • This code should work, it will only render on permalink pages that have pagination. Your posts would need to have pagination for this to work though.

    {block:PermalinkPagination}
    <link rel="canonical" href="{Permalink}" />
    {/block:PermalinkPagination}
    

    If you don't have pagination in each post, this code would work.

    {block:PermalinkPage}
    <link rel="canonical" href="{Permalink}" />
    {/block:PermalinkPage}
    

    If you don't want it to be sitewide, this code should also work and will only render on post pages and not on others.

    {block:PermalinkPage}{block:Date}
    <link rel="canonical" href="{Permalink}" />
    {/block:Date}{/block:PermalinkPage}