Header

Deploy Your Headless CMS with DeployHQ

Node, Open Source, and Tutorials

Post Image

Headless CMS are still the current trend in the web development world. They are a great way to manage content and deliver it to any platform or device you choose, but they can be challenging to deploy! In this guide we will go over the the benefits and challenges of headless CMS and how to deploy them with DeployHQ.

What is a Headless CMS?

A Headless CMS is a content management system where the front end (what you see on the website) and the back end (where you manage content) are separate. Instead of being tied to specific templates or layouts, a Headless CMS focuses just on storing and delivering content.

When writing a blog post with a traditional CMS, you write your content, hit save, and it appears on your site in a predefined format. With a Headless CMS, you write and save your content, and then it can be pulled into any platform or device you choose - whether that's a website, a mobile app, or even a smartwatch. This separation allows for more flexibility because your content can be used in many different ways without changing how you manage it.

Challenges of Deploying a Headless CMS

First, there's the setup. Since the front end and back end are separate, you need to ensure they communicate well. This means you'll need some technical know-how to link your CMS with whatever front-end technology you're using. You might need to learn about APIs, which are like messengers that deliver your content from the CMS to your site or app. If this connection isn't set up right, your content might not display correctly or at all.

Another challenge is the preview. With traditional CMS, you can see how your content will look right away. In a Headless CMS, because the content is separate from the design, previewing changes can be trickier. You might have to build or use a separate tool just to see how your content will appear before it goes live.

Management can also be more complex. With different platforms or devices accessing the same content, keeping everything consistent can be tough. For example, if you update content, you need to make sure every place where that content appears gets updated too. Without a built-in way to check this, it's easy for errors or outdated information to slip through.

Lastly, the learning curve can be steeper. If you're used to traditional CMS where you click, edit, and see the results instantly, adapting to a system where you manage content in one place and see it in another might take some getting used to. Training or understanding how to manage this setup effectively can take time.

Despite these challenges, once mastered, a Headless CMS offers great flexibility and scalability for managing content across different platforms.

Deploying Strapi with DeployHQ

There are many amazing headless CMS platforms out there for you to choose from. In this guide we will be using Strapi as an example. We also have guides for Ghost, ProcessWire, and Drupal available!

Creating a Project

First things first, you need to sign up and log in to DeployHQ. Once you're in, head over to the Projects section and click on New Project. You'll be guided through a wizard to connect your repository.

Setting Up a Dedicated User for DeployHQ

It's a good idea to have a separate user for your deployments. This keeps things tidy and secure. On your server, run these commands to create a new user called deployhq:

sudo adduser deployhq
sudo usermod -a -G www-data deployhq

Configuring Your Server

Now, let's get your server ready. Go to Servers > New Server in DeployHQ. You'll need to:

  • Name your server.
  • Choose the SSH protocol.
  • Enter your server's IP address in the Hostname field.
  • Set the Username to deployhq.
  • Check the box that says Use SSH key rather than password for authentication?.

On your server, you'll need to set up the SSH key. Run these commands as the deployhq user:

su - deployhq
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys

Paste DeployHQ's public key into the authorized_keys file, then save and exit with Ctrl + X, y, Enter. Don't forget to set the right permissions:

chmod 600 ~/.ssh/authorized_keys

Back in DeployHQ, set the Deployment Path to where your Strapi application lives. Make sure to enable Perform zero-downtime deployments on this server to keep things smooth.

If you're using a process manager like PM2, update its configuration to point to /var/www/your-strapi-project/current. Set the Environment to production and enable automatic deploy. Save your server configuration.

If you run into any issues, DeployHQ's has many guides to help you troubleshoot and a brand new AI tool that can help you debug your deployments!

Config Files (Optional)

If you have sensitive files like a .env file, you can upload them securely via Config Files > New Config File. Just copy the contents of your .env file into the config file content field.

Setting Up SSH Commands

To make sure your Strapi application gets built and runs correctly after deployment, you'll need to set up some SSH commands. Go to SSH Commands > New SSH Command and create these commands:

Install Dependencies:

cd %path% && npm install --production

Build Strapi:

cd %path% && NODE_ENV=production npm run build

Restart Strapi (if you're using PM2):

pm2 restart your-strapi-app

Make sure these commands run in the right order.

Deploying Your Project

Now that everything's set up, you're ready to deploy. Click Deploy Project in the header, choose your server and the revisions you want to deploy, then hit Deploy. Your Strapi project should now be automatically deploying whenever you push changes to your repository.

That's it! With these steps, you should have your Headless CMS up and running with DeployHQ, making deployments a breeze. If you need more help, don't hesitate to check out our documentation. You can find more guides here.

Best Practices

As always, the details are key. Here are some best practices to keep in mind when deploying a Headless CMS:

Staging Environment

Staging environments are basically an exact copy of your production environment to test with. They help you to:

  • Test content changes safely
  • Verify API integrations
  • Ensure your frontend works with CMS updates
  • Validate performance optimizations

To set up staging in DeployHQ, simply create a second server configuration with your staging environment details and deploy to it first.

Content and Configuration Versioning

Most outages in the industry are caused by changes to configurations! Versioning your content and configuration is a good way to keep track of changes and make changes reversible.

  • Use Git for version control of your CMS configuration
  • Keep backups of your content database (and don't forget to check if the restore works!)
  • Document content model changes
  • Test content migrations before applying them

FAQ

You got questions? We got answers!

How much does DeployHQ cost?

You can get started for free! All DeployHQ plans cover the basics of deploying your favorite headless CMS. Here's a quick overview:

deployhq-plans

Looking for more? Our Business ($39/mo) and Enterprise ($99/mo) plans include additional features like custom domains, priority deployments, and the ability to deploy behind firewalls.

Start free, no credit card required →

Are Headless CMS good for developers?

Yes! Headless CMS are great for developers because they give you the flexibility to build your own frontend and don't lock you into a specific platform like WordPress.

How do I deploy a headless CMS?

DeployHQ is a great tool for deploying headless CMS applications. It's easy to use and integrates with a wide range of headless CMS platforms.

Do headless CMS scale?

Yes, headless CMS platforms are highly scalable. Since the content management system is decoupled from the frontend, you can:

  • Scale each component independently
  • Use CDNs to distribute content globally
  • Handle traffic spikes more efficiently
  • Add or remove resources as needed

Need more help? Contact our support team →

A little bit about the author

Jonas Scholz | Docker Deployment Automation | DevOps Engineer | Sliplane.io Streamline your Docker container deployments with the easiest platform at Sliplane.io. As a DevOps specialist, Jonas helps developers and businesses automate their infrastructure and accelerate software delivery. Explore simple Docker deployment solutions and DevOps expertise.

Tree

Proudly powered by Katapult. Running on 100% renewable energy.