Back to all articles
How I built my blog with Forestry CMS
Published on
This is the hello-world article for my blog. In this article, I will show you how to integrate Forestry into your blog to handle content management. I was doing some research on the best CMS to use for my blog, and I discovered Forestry from an article by Gift Egwuenu. I was intrigued by the fact that it stores your content in your Git provider. Essentially, you own your content, which is great.
Forestry is a git-based content management system (CMS) for websites and web products built using static site generators. It provides an easy way for you to create and edit the content on your website. Among other things, it provides a WYSIWIG editor for writing. Forestry works by synchronizing content changes with a Git repository.
I built my blog with NextJS, and my posts are saved in markdown. My blog is also hosted on Vercel, so this article is written in that context.
Getting Started
- You need to create an account. You can sign up with GitHub, GitLab or Bitbucket.
- After you create your account, you'll be taken to your dashboard. Click on "Add Site".
- Select a static-site generator. You can also choose from a list of starters if you've not set up a git repo.
- Select your Git provider. In order to import your site, access to your Git provider is required. Forestry supports GitHub, GitLab, BitBucket, and Azure DevOps
- Choose a repository and branch. You can add multiple branches to a repo.
After granting Forestry access to your repo, you'll be taken to your site to configure the CMS sidebar.
Managing Content
For example, I have a folder labelled Blog
on my sidebar which houses my markdown files. This folder is synchronized to a folder called posts
on my repo, where my code processes the markdown for display.
Editor
Forestry gives you a good WYSIWYG editor for writing content. In the image below, on the left is the post's metadata, defined when I configured my frontmatter. On the right is the content body.
You can draft posts and publish when you need to.
Front Matter
There's a dedicated section for configuring frontmatter. Frontmatter is structured metadata that you can use in your markdown files. You can add as many templates as you want. I have one for my posts and it's autogenerated for any new article I want to write.
Choose the Fields and big content area
option if you want to create a template for articles. Each template settings is saved in a yml
file in a .forestry
folder in your repo. As a matter of fact, your forestry configuration settings are saved in a yml
file in the .forestry
folder in your repository.
Media
Forestry supports the upload of images and PDFs. These files can be saved in your repo, or you can connect to a remote provider. Forestry currently supports storing your files in Cloudinary, AWS S3, and Netlify Large Media. I use Cloudinary and it was easy to set up.
Drafts
Usually, you may not be ready to publish an article but you don't want it to show up on your site after you save the article. So how do you go about it?
Forestry has a draft feature but it's only supported for Jekyll and Hugo sites. What I did to fix this issue was to create a toggle field called publish
that is by default set to false. Then in my code where I parse the markdown files, I only parse those where publish is set to true.
Deployment
Forestry's job is to provide a user interface to handle your content. How you deploy your content is up to you. I host my blog on Vercel, with continuous deployment set up. On Forestry, when I create or edit a post and save, it saves the changes to my repo via a git commit which triggers a build from Vercel, and then my site is deployed. Check the docs for hosting guides with a number of services.
Conclusion
I have to say Forestry is an excellent content management platform. The free plan is really generous for my needs. The docs are excellent. I'm really optimistic about it and I hope it turns out great.