3 ms·
Makefiles and Shell scripts (sh/ash/dash/bash/zsh/et. al.) Make will take care of the file discovery, change detection and rebuilding all content files. And so
by techdragon 5y ago
Makefiles and Shell scripts (sh/ash/dash/bash/zsh/et. al.)
Make will take care of the file discovery, change detection and rebuilding all content files. And some simple shell scripting will let you generate minimal HTML with the no frills approach of just embedded big chunks of HTML into your scripts using strings or HereDoc sections depending on personal preferences.
For maximum simplicity I’d recommend writing blog/page content in a “HTML fragment style” where you basically just write the content as text annotated with any explicit HTML formatting like hr or br tags, along with appropriate paragraph tags. This will minimise the complexity of the shell scripts (mostly by eliminating any complicated markup translation mechanisms) you need to write for templating out finished HTML files.
If you want to get fancy add “jq” a widely available json parsing tool available as a static binary for most environments you’ll ever want to work in. Store a “metadata file” in JSON format next to your content. You can use this to automate post author attribution, extra post information like publication dates. As well as making more advanced things like controlling the styling of each item if you want different themes for different kinds of blog content.
You could gradually increase the sophistication of your HTML templating scripts, add some sed and awk to gradually minimise the number of big hand written chunks of HTML your templating scripts contain. But these will if not careful, reduce the flexibility you have by just being able to edit the hand written chunk of template HTML that wraps around your content. Both mechanisms have advantages so I’d recommend using a mechanism like the aforementioned “jq” metadata and an intermediary script layer that uses this metadata to control which scripting path gets used to build a page that way you can easily experiment with new variations in how you render your pages without risking breaking all your existing stuff.