I wanted to convert my small-ish TiddlyWiki site to an Obsidian.md vault, and while the instructions I found on forums, et al, were immensely helpful, I still had to hack at the process a bit.
Note My TiddlyWiki installation is a Nodejs server running on Alpine (via a Docker container), but my Obsidian installation is running on Windows, iOS, and others. YMMV.
My journey ...
-
First, read this forum post and the original blog post to understand the basic workflow.
-
Copy the two Nodejs scripts,
safe-construct.js
andsafe-rename.js
-
Create a custom export template in your source installation for the
frontmatter
section of each converted Tiddler. Adjust this template to your ❤️'s content.
Tiddler template name: $:/core/template/frontmatter
created: <$view field="created" format="date" template="YYYY-0MM-0DD"/>
creator: <$view field="creator" format="text" />
tags:
<$list filter="[all[current]tags[]!is[system]sort[title]]"> - <$view field="title"/>
</$list>
You can read up on the ViewWidget, FieldsWidget, and TiddlerFields to adjust as needed.
- Install html-entities from NPM in order to convert any errant HTML entities in filenames.
npm install html-entities
-
Install pandoc for your OS.
-
Create a new, empty TiddlyWiki installation with the necessary TW plugins for the export and your source TW, and load the old TiddlyWiki site into this new installation.
tiddlywiki --verbose +plugins/tiddlywiki/markdown --load /src --savewikifolder ./dst
Note Adjust the plugins as needed, e.g. add
+plugins/tiddlywiki/tw2parser
to read TW2 files (legacy format files)
- Change into the
dst
directory and render the Tiddlers into two files: a.meta
file which will have the Obsidianfrontmatter
and a.html
file which will have the body of the Tiddler as standard HTML.
tiddlywiki --verbose ./dst \
--render [!is[system]] [encodeuricomponent[]addsuffix[.html]] \
--render [!is[system]] [encodeuricomponent[]addsuffix[.meta]] text/plain '$:/core/templates/frontmatter'
The first --render
produces the HTML body and the second produces the frontmatter
header for the final Obsidian Markdown file into the dst/output
directory.
You might what to run this render process a couple of times to get the resulting files correct.
- Rename all of the rendered Tiddlers, i.e. the
.meta
and.html
files. (Adjust script location accordingly.)
node safe-rename.js output
- Change into the
output
directory and convert the HTML files within the directory into Markdown usingpandoc
.
for f in *.html; do pandoc "$f" -f html-native_divs-native_spans -t commonmark --wrap=preserve -o "${f%.html}.md"; done
-
Change back to the
export
directory and make afinal
directory where the constructed Markdown files will land. -
Construct the final Markdown files, converting the HTML links to Obsidian links.
node safe-construct.js output final
-
Move or copy the
final
directory into your Obsidian vault. -
Profit!
Step seven - no need for ./dst and arguments need to be quoted to avoid interpretation by the shell: