Alternate ways of rendering static urls


I use TiddlyWiki to generate a public second-brain-like website. It is all static files, and I do it via the known static template strategy (with a few non-important changes).

The urls are generated in a very particular way (as depicted here: How do I avoid double URL encoding when rendering URLs in my website?).

I understand this is expected behaviour for maximum compatibility (and that TW should not be expected to work as a fully-functional static website generator). I do wonder, however, if there are alternate ways of mapping each tiddler title to a universally compatible .html file name; something that would bring it closer to the usual standard of url formatting — - instead of spaces, etc — albeit probably at the expense of additional work in linking the static pages.

Thank you!

EDIT: while working on a unrelated issue, I just noticed a definition at the top of the template:

\define tv-wikilink-template() $uri_doubleencoded$.html

I’ll try fiddling with this!

This work, which I believe is scheduled for the next version, speaks to how we might handle urls more cleanly:

Simplify permalinks by CrossEye · Pull Request #7990 · Jermolene/TiddlyWiki5 · GitHub

I don’t know if it needs to change to handle static site generation. I never considered that.


I Think it is reasonable to make use of tiddlywiki “to work as a fully-functional static website generator”. It uses a simple template to generate pages that can be modified to meet various requirements. You could even modify it to generate pages from different page templates, make non static pages and more.

  • However I always think why not make use of full tiddlywikis with there interactive features?
  • Tiddlywiki can be used to generate other tiddlywikis, for example see the innerwiki plugin.
1 Like

Thank you, @Scott_Sauyet, for the link! In the meantime, I also found your own topic on this (URL encoding using a `+` instead of `%20` for a space - #27 by TW_Tones) which I wonder how I did not find earlier? It’s a long discussion, so I’ll get to it tomorrow.

@TW_Tones, I did not know about innerwiki, which is interesting – but indeed I’d rather, for now, have it all be static pages (I think there’s less load on the user, it’s overall simpler, and perfectly meets my needs at this moment).

Yesterday I found about the

\define tv-wikilink-template() $uri_doubleencoded$.html

line on top of the static exporter template. It led me here, but this lets me, at most, go from double encoded to single encoded urls. My point is the same as Scott’s above: I’d rather have + instead of %2520, even if it entails some extra work ensuring there won’t be tiddler title issues.

So, I am now onto finding where lies the definition of $uri_doubleencoded$, so I can try to fiddle with it.

Thank you both for the replies!

When using TW to export to a static site I ended up using a solution TW Jones mentions in one of the threads you referenced:

The title of the wiki is the ‘slug’ - no-caps-and-no-spaces. Then I have a field called pageTitle where I put the “official” title - No Caps and No Spaces. Using the ViewTemplate I then put the pageTitle in place of the tiddler title.

I realize this may be something very difficult to go back and do with a great deal of content but it works great when starting a new project.



In fact, I am now trying to fix this and have already done some work. I understand this might be a bit in vain, as there are upcoming changes to the core, but I really dislike seeing so many spaces in my URLs and my use case is a bit different from what I’ve seen so far - it seems like almost everyone is going for exporting Tiddlywikies, and not generating static websites.

Your approach does work, yes, but I would really prefer not to slug my titles and have real titles; the other way around makes much more sense to me (and it’s more natural) to have a proper title and an associated slug field.

I am generating my own slugs (of course, I might run into trouble, like collisions and such), and am currently looking into how to hijack the exporting tool to use the my-slug field to generate filenames (I expect my-slug.html) instead of using $uri_doubleencoded$. I feel really close to a solution!

(I know this is a bit of a big resurrection of an old thread; please let me know if this is not okay.

I’d also like to thank, again, everyone that has contributed so far. I am not really doing any code that could be useful for the project as a whole, but both in this thread and the one I linked there is a lot of support to achieve a solution, and this is both very heartwarming and a great show of what a great community looks like. It’s been a little over a year of my serious TiddlyWiki usage and I’m very, very happy with it. So thanks for that!)

EDIT: I went a bit further in my inquiries. I realise there are two rendering moments at play here: the first is when the -render command is used to generate the static files; this generates, say, the my%20%spaced%20tiddler%20title.html. However, if “My Spaced Tiddler Title” has further links in its body, then tv-wikilink-template comes into play to generate the href tags necessary for the .html body of the rendered tiddler. So, ideally, I would override both.

For the -render, I think it suffices to use the filename-filter option when rendering, so that is okay - and I would suppose it solved my goal, had I not realised I need to handle linked tiddlers for each rendered tiddler. As for the rest, I’ll try to figure something out that would not be too intrusive with the core modules.

EDIT2: I managed the -render command; that was quite easy. I am now looking into tv-filter-export-link, which should do the rest for me!

EDIT3: yep - I solved it! this was really not so hard and in fact there is barely any core interventions to do.

for future readers, I am creating the slugs outside of Tiddlywiki (I suppose it would not be hard to implement it in JS to run inside the wiki, but my deployment routine is external; anyway — ) and then retrieve slugs both in the -render command and in a custom template for rendering, via the tv-filter-export-link; since it receives the title of the current tiddler as input, all it takes is to add the [get[slug]] filter and any further prefix and suffix needed.

So this is done. Nice! Thanks to everyone!