I’m a big user of both Discourse and Jekyll, and recently I’ve been experimenting with trying to use a Discourse instance as a content management system for a Jekyll static site. I have only just begun playing around with this and part of my reason for posting at this stage is just to see if anyone else has already done this or similar. Alternatively you might have a better way and talk me out of wasting any time on it
How I envisage it would work
-
Markdown content would be edited in a Discourse instance (giving non-technical users a nice UI for editing) and can be easily re-edited, updated etc. Formatting toolbar and other niceties make the non-techy user much happier.
-
In the Jekyll site is a YAML file containing an array of post URLs (or post IDs if we decide the baseUrl of the Discourse is always the same one…) which should be polled for content.
-
A simple Jekyll plugin would run a hook to poll each URL (at each restart of the Jekyll server?) and GET the data. (For many ‘open’ Discourse instances no auth would be required. In some circumstances an API key would need to be supplied)
-
The JSON content is downloaded from the URL by adding
.json
, and theraw
key of this JSON object contains the Markdown as a string wrapped in double quotes. -
Jekyll YAML front matter would need to be added to the Markdown, and cleanup such as the wrapping quotes removed and
\n
newlines replaced. -
Jekyll builds these entire pages into HTML, or you could
{{include file | markdownify }}
them into other pages.
Why bother?
-
Makes it way easier for a non-technical editor or maintainer to update a static site.
-
Ideal if you already have a Discourse and want to make a static website eg for a business.
-
Static sites are cheap, reliable and secure.
-
Why not use Page Publishing? When I’ve tried it, the pages seem to need a lot of work to make them look good. Jekyll allows more control, and of course allows a mixture of Discourse-managed and non-Discourse-managed content sources.
Thoughts from the community? Is this worth pursuing?