DEV Community


How to Automatically Cross-post from Your GatsbyJS Blog with RSS

Dane Stevens
Founder at and full-stack developer.
Originally published at on ・4 min read

Gatsby loves RSS

With the recent exodus from Medium many developers are now creating their own GatsbyJS Blogs and then cross-posting to Medium or publications like

Cross-posting is time-consuming, but necessary to drive traffic to your personal site. Let's look at how we can automate this by adding an RSS feed to your personal GatsbyJS blog.

Add Canonical URL's to Your Blog

What is a canonical url?

Canonical URL for

A canonical url tells search engines which page is the primary or authorative page when duplicate content is found (ie. cross-posting).

Let's install gatsby-plugin-canonical-urls

Quick tip: npm i is an alias for npm install --save

npm i gatsby-plugin-canonical-urls

Note: If you are using gatsby-plugin-react-helmet install this plugin instead: gatsby-plugin-react-helmet-canonical-urls*

npm i gatsby-plugin-react-helmet-canonical-urls

Add plugin configuration to /gatsby-config.js

// In your gatsby-config.js
plugins: [
    resolve: `gatsby-plugin-canonical-urls`,
    // or
    // resolve: `gatsby-plugin-react-helmet-canonical-urls`
    options: {
      // Change `siteUrl` to your domain 
      siteUrl: ``

      // Query string parameters are inclued by default.
      // Set `stripQueryString: true` if you don't want `/blog` 
      // and `/blog?tag=foobar` to be indexed separately
      stripQueryString: true

With this configuration, the plugin will add a <link rel="canonical" ... /> to the head of every page e.g.

<link rel="canonical" href="" />

Install an RSS Feed Generator

We'll use gatsby-plugin-feed to generate an rss feed from our blog posts.

npm i gatsby-plugin-feed

Add plugin configuration to /gatsby-config.js

// In your gatsby-config.js
plugins: [
    resolve: `gatsby-plugin-feed`,
    options: {
      query: `
          site {
            siteMetadata {
              site_url: siteUrl
      feeds: [
          serialize: ({ query: { site, allMarkdownRemark } }) => {
            return => {
              return Object.assign({}, edge.node.frontmatter, {
                description: edge.node.excerpt,
                url: site.siteMetadata.siteUrl + edge.node.fields.slug,
                guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
                custom_elements: [{ "content:encoded": edge.node.html }],
          query: `
                sort: { order: DESC, fields: [frontmatter___date] },
              ) {
                edges {
                  node {
                    fields { slug }
                    frontmatter {
          output: "/rss.xml",
          title: "Your Site's RSS Feed",
          // optional configuration to insert feed reference in pages:
          // if `string` is used, it will be used to create RegExp and then test if pathname
          // of current page satisfied this regular expression;
          // if not provided or `undefined`, all pages will have feed reference inserted
          match: "^/blog/",

NOTE: This plugin will only generates the xml file(s) when run in production mode! To test your feed, run: gatsby build && gatsby serve

Here's what our feed looks like:'s RSS Feed

For more information on configuring your feed check out the plugin docs.

Connect to Your RSS Feed

  1. Log in to your account
  2. Go to: Settings > Publishing from RSS or
  3. Add your "RSS Feed URL" e.g.
  4. Check "Mark the RSS source as canonical URL by default
  5. Click "Update"

Screenshot of RSS settings

Connect Medium to Your RSS Feed

The connection for Medium is not quite as straight-forward, but simple enough using Zapier.

Head on over to Zapier and create a free account.

"Make a Zap"

  1. Choose "RSS" as your "Trigger App"
  2. Select "New Item in Feed"
  3. Paste in your "Feed URL"
  4. Select a sample from your feed.
  5. Choose "Medium" as your "Action App"
  6. Select "Create Story"
  7. Authorize your Medium account
  8. Select your fields: make sure you select your Canonical URL
  9. Send a test to Medium
  10. Finish and turn on your Zap

Screenshot of connecting RSS to Medium with Zapier


Make sure Google gives you credit for your content by using Canonical URL's.

I hope you found this helpful and that it saves you lots of time cross-posting your content!

Originally published at

Discussion (0)