Implement an RSS feed from JSON to XML in Gatsby.js

Christina Hastenrath
The Startup
Published in
6 min readJun 27, 2020

--

A step-by-step tutorial on how to implement an RSS feed from JSON by converting it to XML and creating a static page in Gatsby πŸš€

Photo by Cookie the Pom on Unsplash

Implementing a site-wide RSS feed in Gatsby can be done very easily. I can recommend implementing the official Gatsby feed plugin.
In this tutorial, I want to show you how you can implement an RSS feed for a specific URL or page. In my case, the data for the RSS feed was provided to me via a REST API endpoint that returned JSON.

πŸ’‘This tutorial assumes you already have a Gatsby site setup and running. If you are new to Gatsby, I can highly recommend the Gatsby docs to get started.

Here are the steps that I am going to walk you through in detail in this tutorial:

β€” Test your API endpoint with `Postman`
β€” Call JSON in /gatsby-node.js with `Axios`
β€” Shape JSON by turning it into a JavaScript Object
β€” Convert the new object to RSS XML with `jstoxml`
β€” Use fs from Node.js to create a new file rss.xml
β€” Test your new RSS feed with an RSS validator

Without further ado, let’s get started πŸ™Œ

The first step is to call the API endpoint and make sure that it returns the correct JSON. Postman is an excellent tool to…

--

--

Christina Hastenrath
The Startup

Molecular Biologist turned Software Engineer. I write about my code. Connect with me on Twitter @etTinchen