Thanks @kepano and @Joschua for the instructions! I’ll add what I had to change for Windows, plus some adjustments/details if anyone else wants to play with it
The first thing to look out for on Windows is, you need to open your PowerShell in the folder where you want to create your tiddlywiki server folder in - if you just leave it on the admin PowerShell, it’ll create it in system32
and you’ll have permission problems when you try to do anything with it.
about exporting the tiddlers to html files:
@sweenejp I don’t know if you still need to know this, but for you or anyone else looking to do this, to use the custom template, you need to leave the tiddlywiki server running in a different terminal window, then it’ll take the template flag. You do need to create that tiddler and have it in the same tiddlywiki you’re exporting from - in Windows, I just created a tiddler called custom-template
, because having $
in the title was giving PowerShell problems. I don’t think it matters what you call it, as long as you use its full name in the template flag.
I also ended up exporting the metadata into a separate file, like the original linked instructions suggested, mostly because the note transclusion wasn’t working for me the way I wanted when I made the text
a part of the template. So my full code for the render was the following, with the tiddlywiki server running:
tiddlywiki --render [!is[system]] [encodeuricomponent[]addprefix[tiddlers/]addsuffix[.html]] --render [!is[system]] [encodeuricomponent[]addprefix[tiddlers/]addsuffix[.meta.html]] text/plain custom-template
My custom-template
- very much @kepano 's code, with slight changes - looked like this:
created: <$view field="created" format="date" template="YYYY-0MM-0DD"/>
title: "<$view field="title" format="text"/>"
<$fields exclude='text title bag tags type created modified' template='$name$: $value$
'>
</$fields>
tags:<$list filter="[all[current]tags[]!is[system]sort[title]]">
- <$view field="title"/></$list>
This outputted an html file that seems to have the best results when put through pandoc, and a metadata file like so:
created: 2015-07-27
title: "Adventure making checklist"
creator: Vero
modifier: Vero
tags:
- ttrpg
- how-to
After that, cd output\tiddlers
(or just cd output
, if you didn’t use the addprefix[tiddlers/]
version), and here’s the actual difference for Windows.
This needs to run in PowerShell specifically, with the actual path being the path to your tiddlywiki server:
$files = Get-ChildItem -Path C:\Users\username\Documents\tiddlywikiserver\output\tiddlers -Recurse -ErrorAction SilentlyContinue -Filter *.html |
Where-Object { $_.Extension -eq '.html' }
foreach ($f in $files) {
$newName = $f.Name + ".md"
pandoc "$f" -f html-native_divs-native_spans -t commonmark --wrap=preserve -o "$newName"
}
The markdown files created this way don’t need to be search+replaced for escapes, and seem to look fine, though I’m still going through mine. Still, this output seems to need the least work while keeping the most semantic tags from the html versions, which works for me
I then cleaned up the filenames using Bulk Rename Utility, and created a Templater template that lets me add the meta into a yaml frontmatter from the meta file into the content file. You need to have both the files in the same folder in Obsidian and their names, if you used the --render
I did, are the same plus .meta
for the metadata. Open the content file, leave your cursor on the beginning of the file and apply the template:
---
<% tp.file.include(tp.file.find_tfile(tp.file.title + ".meta")) %>
---