A simple blogging platform
I don’t want a database driven website. I don’t want to have a complicated CSS website. I don’t really want to worry about a site being responsive or not. (Yes, it’s nice, but do I want to worry about it?)
No, all I really want from a blogging platform is a simple core:
- Write new drafts as simple markdown files
- Code highlighting, unsurprisingly
- Have the resulting site entirely statically generated, and pushable to the server using rsync.
- Preview draft posts on a live site
- Move a draft from being a draft to being a public post (trivially)
- Have non-blog-post/etc entries in the same system (like the home page of the blog) - again in markdown
- Versioning/rollback to be git based
- Good enough CSS that makes reading content nice enough on a mobile and desktop
- Simply have custom versions for different networks
- pre-moderated comments handled by Disqus
- Short and simple codebase
Most of these options exist in a variety of systems. Indeed, I’ve previously used “blogophile” for a number of years. However, all of the above isn’t generally available without hacking something together to use with these things. Also their codebases tend to get larger and become abandonware. At which point you’re back to hacking something.
So rather than hack away at modifying something else, I figured I might as well throw something together that does all this for me. Is it great ? No. It’s good enough and that will do. It satisfies all the above requirements though, which is what I’m after.
It’s also 245 lines. It’s short simple enough to extend or hack into something else later. The whole thing code and blog are in a single private git repo.
Repo Structure
Directory structure, relative to TLD:
.
- Just contains a Makefile and build script- Makefile - used to simplify making the site to publish to the public and staging server
src
- used to generate the actual site. Directories preceded by “_” are not replicated over to the serverdrafts
- draft posts are editted hereposts
- when happy with a post, move it here and precede name with YYYYMMDD_panels
- Various pieces of HTML and HTML templates used to build the sitepage.html
- base html template for pages.- Other html fragments here get pulled in via simple template directives.
_templates
- Template posts
main
- used as a build directory. This is replicated onto the server when populateddrafts
- draft posts are generated here. Only replicated to staging serverposts
- published posts are generated here. Replicated to staging server and to public server.
Workflow
- Create new file in src/drafts based on src/_templates/template.post
- Edit the meta data, and post content
make stage
- builds the site and pushes to stage server using rsync- Check server content is OK. Repeat previous 2 steps as necessary
make publish
- builds the site and pushes to public server using rsync- Assuming happy, add changed files to git (as and when) and push to private repo
Requirements
- Just uses
python3
,python3-markdown
, andpython3-pygments
(I use ubuntu, so these are the package names for 20.04)
Future?
I’ll probably add small bits and bobs, but not likely to release this anytime soon - it fits my requirements - probably not yours. It’s possible I might at some point though if it grows at all.
If there’s interest though I could detail some of the more interesting bits about how this works. If you’re interested, leave a comment :)
Updated: 2021/01/03 23:59:58