Sample Static Blog, Tags. A barebones header, replace me!

Creating A Static Blog

2021/4/6 20:59

Overview

(This is generated from the examples in https://github.com/welford/twstaticblog/ 👍 )

I keep notes on various things in Tiddlywiki and it is very useful to be able to export my blog from the same resource. Currently TiddlyWiki has a good but bare bones static export mechanism, I have made some plugins to enable something more along the lines of what I want in a static blog.

Put simply, if I tag any tiddler within my tiddlywiki with a special tag e.g. blog then that tiddler will be included as part of my blog when I run the export batch file. The tags used to specify what is and what isn't an export target are configurable.

I use these plugins to generate http://phasersonkill.com/

The code for this example can be found here: https://github.com/welford/twstaticblog (see example folder for this very file)

  • this guide is windows specific in places
  • you will need node.js follow the tiddlywiki guide for details

Plugins

This actually required two plugins. One helper that exists within your tiddlwyiki, and another export plugin you use in a Wikifolder

Helper

https://github.com/welford/twstaticblog/tree/master/helper

Locally available here : $:/plugins/welford/twstaticblog/helper

Exists within your Tiddlywiki and lets you customise the blog's output without having to worry about the format of your own wiki changing. By editing the tiddlers in this plugin you can change the name of the blog, which tags define your blog, how posts are linked to, and several other things.

Exporter

https://github.com/welford/twstaticblog/tree/master/export
Invoked when exporting the blog, this plugin swaps out some of the core view template tiddlers for those in the helper and as such should not be imported into your own TW. It also contains the templates used when constructing each type of page (The types, discussed below, are Blog Post, Index, Framework, and Tag)

Helper Details

Configuration

All the tags listed below are fully customizable:

plugin tiddlerpurpose
$:/plugins/welford/twstaticblog/helper/ctrl.postDefines which tags constitutes a blog post, defaults to blog
$:/plugins/welford/twstaticblog/helper/ctrl.frameworkDefines which tags constitutes a blog framework blog-framework
$:/plugins/welford/twstaticblog/helper/ctrl.donotexportDefines which tags should not be exported even if they are tagged as a blog posts or blog frameworks blog-donotexport blog-draft
$:/plugins/welford/twstaticblog/helper/ctrl.donotindexDefines which tags will filtered from the index post unindex
$:/plugins/welford/twstaticblog/helper/ctrl.hiddenDefines which tags will be excluded from tag posts and from the tag lists below the title of artiles. blog blog-donotexport blog-draft blog-framework unindex

ctrl.post

Tag any article blog and it will be exported as part of your blog using the templater $:/plugins/welford/twstaticblog/helper/template.post.html . The output directory will be ./YYYY/MM/DD/[tiddlername].html based on their creation date of the article.

You can change the tags which define a blog post via $:/plugins/welford/twstaticblog/helper/blogentrytags

e.g. This post you are reading

template.index.html

Any recently created article tagged with blog will be included in index.html using the $:/plugins/welford/twstaticblog/helper/template.index.html. This can be prevented by also adding the tag unindex

e.g. the exported index.html

Framework

Tag any article blog-framework and it will be exported as part of your blog as a "framework" post using the template $:/plugins/welford/twstaticblog/helper/template.framework.html. The output location in the root directory. I define a framework article as being a post which helps you navigate the site or one that is accessabe everywhere. I have included a few example framework posts in the helper plugin.

e.g. Tags, About both linked to at the top of this page

Tag

As this is a static site generator there is no search functionaity. My plugin auto-generates tag posts, using the template $:/plugins/welford/twstaticblog/helper/template.tag.html, based on any tag in blog or framework posts as a kind of simple site-map. You can exclude tags from being included in this by adding them to the tag list in $:/plugins/welford/twstaticblog/helper/hiddentags

By default the following are excluded:

e.g. example random unique tag <- you can click on these and jump to specified tag page.

Static Bannner

A banner can be added to the top of every page via $:/plugins/welford/twstaticblog/helper/blog-banner in my case I use it to link to some of the framework posts.