Urgent.News

What's breaking now, across thousands of outlets.

Editions

Tech

Cross-posting to dev.to without giving away your SEO

Every article I write lives on my own site first. A copy goes up on dev.to a day or two later, and that copy reliably gets more readers than the original does. One piece has 106 views over there. My own analytics can't honestly tell me how many humans read it here, which is a separate mess I wrote about last week. So I am deliberately publishing my best work somewhere with more traffic than my…

I write my articles first on my site, then publish a copy on dev.to a day or two later. This strategy gets my work more readers than if I just left it on my own site. However, dev.to's analytics don't accurately reflect how many readers see the article here. So, I publish my best work on dev.to, a site with more traffic, using a domain I don't own.

The key to this strategy is a field in the dev.to API called canonicalDi. It's not something you set, but an order you must maintain. Search engines have to choose one URL to rank and treat as the original when two URLs serve the same article. By setting the canonical URL, dev.to knows which one is the original. Setting the canonical URL is a hint, not a directive. Google considers it just one signal among many, with the date being the other important factor.

My workflow ensures the canonical URL must exist before the mirror goes live. I enforce this by refusing to publish until the canonical URL is set correctly. The cron job runs daily at 07:00 UTC and flips the articles' publication dates when their day arrives. The human decision is the merge, and once that happens, there's nothing left to do.

However, I once published an article manually on dev.to weeks before its scheduled publication date. This created a problem because my own site's JSON-LD used the frontmatter date, making it appear as though the article was published earlier than it actually was. The issue was resolved by a one-line change to the date in the frontmatter.

The slug, which is used to build the URL, is validated before anything else. This check ensures no unwanted characters are included, and it costs only one line of code. The script never republishes the same article, as it checks for existing articles with the same canonical URL. The slug is validated before any other step, ensuring a clean and efficient publishing process.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Friday 21 August →