Discourse as a CMS for static site generators

Continuing the discussion from Develop new landing pages for Pavilion using Hugo:

I’ve been working today on a rough first draft of a script which will pull content from a Discourse site in raw markdown and save it to file in a static site repo. It’s really a very simple script at this stage, and is part of my ‘rehabilitation’ back to Ruby after around 2 years in Python and NHS politics!

The target audience is existing admins of Discourse who want a simple static site and want to manage the content for this in Discourse.

It takes a YAML array of Topic URLs and it will parse these


  • The parsing of URLs isn’t yet very robust and if you give it anything that isn’t like https://meta.discourse.org/t/welcome-to-meta-discourse-org/1 it will probably break something.

  • I haven’t tested this properly in situ connected to a Jekyll site. That’s probably fairly important.

  • I’ve tried to design it so that it doesn’t actually matter whether you are using Jekyll, Hugo, Gatsby, or any other static site generator.

  • I need to make it into a Gem so that it’s easier to install globally as an executable.

  • Right now I’m assuming that the markdown content is in a publicly-visible Discourse topic. We can in the future add Discourse API key support so that it could request data from a private topic, but that’s not a priority yet. I’m assuming that since the content is going to be built into a static website that you aren’t bothered about the page source being in a public topic.

CC @keegan

Comments, thoughts, and ideas welcome.
Needs a better name I think.
I’m happy to move to Pavilion repo, but at the moment I don’t think I have write access to paviliondev.


Interesting! I’ve just invited you back to paviliondev.

Pulling the content from the frontend like this works fine for straightforward content, however you’ll have a bit more flexibility doing it on the backend.

the basic backend setup would be:

  1. Designate a category to manage the content

  2. Use discourse events to capture markup after create, update and delete posts in that category.

  3. Push markup to external repo / data store for static site.

1 Like