Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rel=canonical to Tumblr #288

Closed
konklone opened this issue Oct 2, 2014 · 4 comments
Closed

Add rel=canonical to Tumblr #288

konklone opened this issue Oct 2, 2014 · 4 comments
Assignees

Comments

@konklone
Copy link
Contributor

konklone commented Oct 2, 2014

We need to add rel=canonical to our Tumblr blog. I did this in #287 for our staging site. However, I think it will require drudge work in Tumblr, and manual pasting of our blog URLs. This is because there's not a clean one-to-one mapping of URLs.

In other words, our Tumblr URL is http://18fblog.tumblr.com/post/96977653581/the-encasement-strategy-on-legacy-systems-and-the and our live URL is https://18f.gsa.gov/2014/09/08/the-encasement-strategy-on-legacy-systems-and-the/. You can't just switch the domain.

Since the live URLs are constructed from a Tumblr import (and they share slugs), it might be possible to have Tumblr automatically assemble the URLs from its knowledge of the post's slug and publication date. We'd have to research that. Otherwise, this is a matter of someone spending some time in Tumblr clicking through and copy/pasting and saving posts, one by one.

@konklone konklone self-assigned this Oct 7, 2014
@konklone
Copy link
Contributor Author

I cannot figure out how to get this to show up properly in Tumblr themes.

I've set a "Content source" for the FOIA and FEC posts in Tumblr, for the 18f.gsa.gov equivalent. The via link shows up properly in the bottom-right of the post, using the following HTML already in the theme:

{block:ContentSource}
  <li class="source">via <a href="{SourceURL}">{SourceTitle}</a></li>
{/block:ContentSource}

And then I copy and adapt this to the top of the page:

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

But nothing shows up. And if I remove the block stuff, and force the <link> tag to be displayed, the link shows up blank. I'm not sure what's going on at all.

@konklone
Copy link
Contributor Author

Finally got this working!

    <!-- redirect SEO to 18F site where possible -->
    {block:Posts}
    {block:PermalinkPage} 
    {block:ContentSource}
    <link rel="canonical" href="{SourceURL}" />
    {/block:ContentSource}
    {/block:PermalinkPage} 
    {/block:Posts}

    {block:IndexPage}
    <link rel="canonical" href="https://18f.gsa.gov" />
    {/block:IndexPage}

It's mildly hacky, but it achieves what we want:

  • http://18fblog.tumblr.com -> https://18f.gsa.gov
  • http://18fblog.tumblr.com/post/99405195909/were-moving-our-blog -> [nothing]
  • http://18fblog.tumblr.com/post/99384055853/18f-open-source-hack-series-midas -> https://18f.gsa.gov/2014/10/01/open-source-hack-series-midas/

The home page points to the new home page, a Tumblr post with no analogue on the Jekyll blog doesn't point anywhere, and a Tumblr post with an analogue on the Jekyll blog points to its analogue.

This was surprisingly annoying, as there are some subtleties about when and how Tumblr tags work that took some experimenting.

Now I need to go back and mark the "source" for each Tumblr post that has an analogue. I'll do that before closing this ticket.

@konklone
Copy link
Contributor Author

Done! I've updated every Tumblr post with a source link to its Jekyll analogue. Only the "We're moving our blog!" post doesn't have one.

Here's the current state of Google when searching for "18f blog":

before

Hopefully it won't be too long until that changes!

@AlbertoFdzM
Copy link

You made it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants