Import Ghost CMS articles into Hashnode

Photo by Ferenc Almasi on Unsplash

Import Ghost CMS articles into Hashnode

Few easy steps to get your articles

Theo van der Sluijs

Published on Dec 20, 2021

3 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

Importing your articles from the Ghost CMS is very easy, you can do this by using the Ghost RSS. There is only one BIG problem. The standard RSS feed only displays 15 articles.

In my case this is not enough. I have 63 articles I want to import. To solve this you have to create your own RSS feed, if you follow this article you can also import more then 15 articles.

Create limitless RSS feed

There are a few steps you have to follow to create your own RSS feed in Ghost

Change the routes.yaml file

First you have to download the routes.yaml file from you Ghost site by going to -> Settings -> Labs

Ghost CMS Settings Labs Routes.yaml Scroll down and click on the link "Download current routes.yaml".

Open the Yaml file with a Texteditor like Notepad++ or Bbedit and change this line:

routes:

to

routes:
  /news/rss/:
    template: news/rss
    content_type: text/xml

Download the active Ghost theme

Then download your theme from ghost by going to -> Settings -> Design

And click on the left site at the bottom on "Change theme"

change theme

In the next screen click on "Advanced" and behind the current active theme click on the 3 dots and then click on "Download".

Schermafbeelding 2021-12-20 om 14.45.20.png

Unzip the theme.

Create the new Ghost RRS file

Within the theme folder create a folder named : news.

In this new news folder, add a file called rss.hb and add the following code in this file.

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
<channel>
<title><![CDATA[ {{@site.title}} ]]></title>
<description><![CDATA[ {{@site.description}} ]]></description>
<link>{{@site.url}}</link>
<image>
    <url>{{@site.url}}/favicon.png</url>
    <title>{{@site.title}}</title>
    <link>{{@site.url}}</link>
</image>
<lastBuildDate>{{date format="ddd, DD MMM YYYY HH:mm:ss ZZ"}}</lastBuildDate>
<atom:link href="{{@site.url}}" rel="self" type="application/rss+xml"/>
<ttl>60</ttl>

{{#get "posts" limit="all" include="authors,tags"}}
    {{#foreach posts}}
    <item>
        <title><![CDATA[ {{title}} ]]></title>
        <description><![CDATA[ {{excerpt}} ]]></description>
        <link>{{url absolute="true"}}</link>
        <guid isPermaLink="false">{{id}}</guid>
        <category><![CDATA[ {{primary_tag.name}} ]]></category>
        <dc:creator><![CDATA[ {{primary_author.name}} ]]></dc:creator>
        <pubDate>{{date format="ddd, DD MMM YYYY HH:mm:ss ZZ"}}</pubDate>
        <media:content url="{{feature_image}}" medium="image"/>
        <content:encoded><![CDATA[ {{content}} ]]></content:encoded>
    </item>
    {{/foreach}}
{{/get}}

</channel>
</rss>

Zip the complete theme folder.

Upload the new Ghost theme with RSS

And then in Ghost go to -> Settings -> Design

And click on the left site at the bottom on "Change theme". In the next screen click on "Upload". Add the theme zip and upload it.

Upload the new Routes.yaml file

Now you are ready to upload the new routes.yaml file, to do this go to -> Settings -> Labs

Ghost CMS Settings Labs Routes.yaml Scroll down and click on the link "Upload Routes Yaml".

Choose the changes routes.yaml file and upload it.

Now you have a created a new rss feed for your import.

You can test the RSS by going to https://[yourdomain]/news/rss

This should display all your articles.

Now you are ready to import them in Hashnode.

Import ghost articles into Hashnodes

To import the RSS feed into Hashnode login to Hashnode and go to your Blog Dashboard.

On the left side of your blog dashboard menu click on "Import".

Import Ghost articles into Hashnode

In the import screen click on RSS Importer.

In the RSS importer screen, fill in the url where the new RSS can be found, like https://[yourdomain]/news/rss

And hit the "Import" Button

In the next screen select the articles you want to import and choose "Import as Draft".

Click next and you are done. Leave the screen open as it takes a while before the system is ready.

Last manual stuff to do.

To be sure that articles are okay, you will have to open every and each one of them and check them visually. Change stuff to your needs, so it will improve the article within Hashnode.

Unfortunately, this tool does not import everything. For example, SEO-related matters will not be imported. You will have to fill in the SEO title and SEO description by hand (copy from the Ghost environment)

And that's it! In this way you can easily transfer your articles from Ghost to your Hashnode environment.

 
Share this