DEV Community

Discussion on: I'm concerned with the move that FreeCodeCamp just pulled by leaving Medium

ossia profile image
Quincy Larson

Can you point to some such articles? I can check their canonical links.

Thread Thread
laurieontech profile image
Laurie

There are screenshots in the post that we're commenting on that show examples of this happening with Ali's post. The original canonical_url on medium points back to her dev.to post. The new site points back to the medium post, a different url.

Thread Thread
lkopacz profile image
Lindsey Kopacz

I would check the one Ben put in this blog post.

Thread Thread
joshcheek profile image
Josh Cheek

Looks like you might be able to get it via the API: github.com/Medium/medium-api-docs#...

Eg they say a post object has a canonicalUrl, attribute. I can't tell from reading the docs, whether you can GET them via the API. All the examples are creating Medium posts via POST requests, and none are showing existing posts via GET requests.

But you presumably found some way to get it, so if you're getting it through an API endpoint, then check it for the canonicalUrl attribute. And if you're getting it by scraping it, then check for the link tag, eg this prints the expected value:

curl -s https://medium.com/free-code-camp/the-most-important-non-programming-skills-for-programmers-d39fadc1a0fa \
 | ruby -ne '~/<link\s+rel="can.*?"([^"]*)">/ && puts($1)'

(in reality, I'd use the CSS selector link[rel="canonical"], but I wanted an example that didn't require installing fancy tooling)