Blogging isn’t just about writing quality content, but also ensuring that it reaches as many members of your audience as possible. This means that bloggers have to post an article multiple times on different platforms. This often entails ensuring that the formatting and layouts are consistent across platforms, which tends to be a time consuming (and exhausting) ordeal.
Automating these processes can save large amounts of time and effort, allowing bloggers to reclaim time to focus on what they do best — writing. This tutorial will teach you how to post blog posts to multiple blogging platforms automatically.
In this tutorial, we’re going to create and store all our posts in one central platform — Strapi. It is a headless CMS which will store all our content. We will use n8n to create a workflow that will take content from Strapi using webhooks and create posts on Medium and Dev.to using their REST APIs. Strapi supports post creation through markdown formatting, which will help maintain the layouts of articles across platforms.
1. Getting ready
This tutorial guide assumes that you already have Strapi and n8n set up and running. In case you don’t already have these services running, you can run them using
If you get stuck, or prefer to not use Docker, you can check out alternative install methods here (strapi setup guide).
Setting up Strapi
Then, start the service by running:
docker-compose up -d
Setting up n8n
If you prefer not to use Docker, you can check out the alternative install methods in the docs.
docker run -it — rm \
— name n8n \
-p 5678:5678 \
-v ~/.n8n:/root/.n8n \
n8n start — tunnel
Note: This is only meant for local development and testing. For information on how to deploy n8n in a production environment, please refer to the n8n setup guide.
Make sure that all the services have been started using
docker ps. You should be able to see two running containers, one for Strapi and one for n8n.
You can also follow along this guide by copying the workflow from n8n.io and making appropriate changes at each step.
2. Setting up a Webhook node
In this workflow, we will receive all our content from Strapi to distribute it across various platforms. We will accomplish this using the Webhook node.
Add a new node by clicking the + button on the top right of the Editor UI. Under the Triggers section, select the Webhook node. Then, select the POST option for HTTP Method. Enter a webhook Path. This can be any name you want.
Now, save the workflow. This activates the webhook. Finally, copy the test webhook URL (we will need this later). Here’s a GIF of me following the steps mentioned above.
3. Creating a collection in Strapi and setting up the webhook
Strapi stores all content in the form of collections. These are user defined stores of data. We will first create a collection and then set up the webhook that we created in the previous step.
Create a collection with the fields for a blogpost:
- Title — Short text
- Post Datetime — Datetime
- Post Content — Rich text
- Feature Image — Single media
- Tag — Enumeration
Head over to the settings section and set up a webhook for a Create Entry event of your new collection. Paste the n8n webhook URL you copied from the previous step. Now, save your changes by clicking on the Save button.
4. Creating POST requests for the Dev.to API
Now that we have all our content being sent from Strapi to n8n, we need to send that information from n8n to several blogging platforms. Most blogging platforms have a RESTful API using which we can make a post.
Let’s start with Dev.to as an example. Go ahead and obtain an API Key from the Settings section of your account.
First, create a sample post and retrieve the data model from Strapi, by clicking on the Execute Node button and then creating a new sample post in Strapi. It should look something like the image below.
Note: You will need to use the test webhook to be able to view the data that n8n processes as shown above. The production node does not display retrieved data in the workflow editor. We recommend that you use the test webhook to configure the workflow.
Next, we need to send the data to Dev.to via their REST API. One of the ways to do this is by using a POST request. POST requests are a type of web requests that can send data to a server by including it as a ‘payload’. In n8n, POST requests can be created and used via the HTTP Request node.
Now, using the HTTP Request node, we can send the data to dev.to. Set the Authentication to ‘Header Auth’ and use the API key from your Dev.to account (you can create one in Settings > Account) to authenticate. Set JSON/RAW Parameters to true (turn the switch on). Set the request method as POST and paste the API endpoint in the URL (https://dev.to/api/articles in our case). Using the Add Option menu, select Body Content-Type and set it to ‘JSON’.
The final step to create the node is to add the request body, or the payload, in JSON format. This will contain all the data that is needed to make a post. To dynamically change the data based on previous nodes, we will use the powerful “Add expression” tool. You can access this by clicking the ⚙️ (gears) icon and choosing Add Expression.
Now, select the following variable:
Nodes > Webhook > Output Data > JSON > Entry > Title
Here’s an example of me adding an expression to a node.
Having previously read through Dev.to’s API documentation, I chose all the information that I wanted to send to Dev.to and encoded it as JSON.
"title": "Post Title",
"body_markdown": "I love n8n!",
"TutorialSample", "Guide", "Instructional",
"series": "n8n Guides",
For consistency, I chose to only include the fields that both Medium and Dev.to would support.
If you want to include or exclude information, please refer to Dev.to API reference.
Next, test this node by clicking Execute Node to run this node. Then, head over to Dev.to and check if a new post has been created. If you see a new post; it means you’ve set this up correctly.
Here’s a GIF of me following the steps mentioned above.
5. Creating POST requests for the Medium API
We now need to send the data to Medium via their REST API, via a POST request. To do this, we will use the HTTP Request node again. However, Medium’s REST API requires the user to follow a couple of extra steps.
First, we begin by changing the endpoint URL by adding in your authorid.To do this, you need to find your authorid (Refer: https://github.com/Medium/medium-api-docs#33-posts) and then replace it in the following:
Next, you need to email firstname.lastname@example.org to gain API access (Refer:https://github.com/Medium/medium-api-docs#22-self-issued-access-tokens). Once you have API access, create an API token and copy it (we will need this in the next step).
Let’s create the node. Set the Authentication to ‘Header Auth’ and add the Key as ‘Bearer’ and the password as the API key you obtained for authentication. This time, instead of writing the JSON payload ourselves we use the built in menu-based options to add JSON Request Parameters. I chose to use a basic set of parameters, but you can find a list of all supported parameters here and change them up according to your preferences.
Here’s a list of body parameters I used:
- title — using data from the webhook node
- contentFormat — markdown
- content — using data from the webhook node
- tags — using data from the webhook node
- canonicalUrl — using data from the webhook node
- publishStatus — public
You can add the parameters in the Body Parameters section using the names above and mapping the data from the Strapi Webhook node.
Then, test this node by clicking Execute Node to run this node. Then, head over to Medium to check if a new post has been created. If you see a new post; it means you’ve set this up correctly. Continue to the next step.
Here’s a GIF of how I set up my HTTP Request node for Medium.
6. Executing the workflow
First of all, change the webhook in Strapi from the testing to production and activate the workflow. The test webhook is meant only for configuration and setting up the webhook. It is only active for 180 seconds. The production webhook on the other hand, listens for requests all the time.
Create a post in Strapi and save it. Head over to Dev.to and Medium to check if the blog posts have been created (it might take a few seconds).
Here’s a GIF of me executing my workflow.
The post has shown up with the correct content and tags on both platforms. We’ve set up n8n to cross-post content to both Medium and Dev.to.
And, that’s it! Congratulations, you have just automated cross-posting across blogging platforms 🎉
Adding more platforms
Since n8n supports webhooks and HTTP requests; you can add any blogging platform that supports a RESTful API using a similar set of steps (consult the documentation) for the appropriate settings.
You can also automate cross-platform updation and deletion of posts; making Strapi a powerful tool to manage and deliver your content across several online platforms.
You can also experiment in a similar manner with social networking workflows such as twitter, announcing a new blog post via a tweet. Such companion social media pages for blogs ensure that your content reaches even wider audiences.
In this tutorial, we learnt to automate cross-posting of blog posts using a single source of truth to ensure consistency and reduce effort. We also discussed the possibility of using companion workflows to handle the update and removal of content and increasing visibility and reach by complementing using social media nodes.
Writing is a creative industry and everyone has their own style and way of doing things — a workflow that they prefer. n8n can help automate the repetitive tasks of your workflow. Which parts of your daily life are repetitive and tedious? What will you automate?