How to customize permalinks?

Is it possible to customize the permalinks?

Currently, TW generates permalinks from the title of the tiddler, which can get quite ugly. like

https://groktiddlywiki.com/read/#Requirements%20for%20the%20Sample%20Wiki

It also affects SEO and sharability. Though I know, TW as a whole is not web crawler friendly. But URL also affects SEO.

So is it possible to have custom permalinks for tiddlers regardless of title?

https://groktiddlywiki.com/read/#sample-wiki-req

This discussion seems relevant

https://groups.google.com/g/tiddlywiki/c/QOzs3CVtosU/m/XpqE0X_QBQAJ

So tiddler titles are like UUID.

One possible workaround is that

  1. set the title to a pretty URL, like sample-wiki-req

  2. Set a custom field like human-title to “Requirements for a Sample Wiki”

  3. modify the view template to show the value of the human-title field as the title instead of the default title field

Need to test this idea though.

There are several ways to do this :

With filters

You can use a filter in the url, something like this could work :

https://groktiddlywiki.com/read/#:[{id!!10}]

In the tiddler id, create a field “10” or whatever else and put the name of the tiddler you want to link inside. This way you can create shorter links.

Other examples that all point to the same tiddler:

Using filters, I can transform your link from this :

https://groktiddlywiki.com/read/#Requirements%20for%20the%20Sample%20Wiki

to this :

https://groktiddlywiki.com/read/#:[all[shadows]search:title[Requirements]]

With templates

If you dont want to use filters, you can create a custom missing tiddler template, or a custom Story Tiddler Template Filter.

E.g :

In a tiddler with the tag $:/tags/StoryTiddlerTemplateFilter and the field list-before :

[{!!title}is[missing]prefix[/]then[RedirectTemplate]]

Then in RedirectTemplate :

\define close()<$action-sendmessage $message="tm-close-tiddler" $param=<<redirect-title>> />
\define edit()<$action-sendmessage $message="tm-edit-tiddler" $param=<<currentTiddler>> /><<close>>
\define delete()<$action-sendmessage $message="tm-delete-tiddler" $param=<<currentTiddler>> /><<close>>
<$let redirect-title={{!!title}}>
<$tiddler tiddler={{{ [{!!title}removeprefix[/]]:map[all[tiddlers]article{!!title}] }}} >
<$messagecatcher $tm-close-tiddler=<<close>> $tm-edit-tiddler=<<edit>> $tm-delete-tiddler=<<delete>>>
 <$transclude tiddler="$:/core/ui/ViewTemplate"/>
</$messagecatcher>
</$tiddler>
</$let>

That way I can link to my tiddler using its article field, without using a filter in the url:

https://demos.tiddlyhost.com/#/a-long-title-made-shorter

redirect.json (1.0 KB)

Using your idea (probably the best solution)

The neat thing about your idea is that the permalink button works, there is no need for using a message catcher widget, only the title needs to be modified. I already made a template for that :

Caption_instead_of_title_with_character_formatting.json (594 Bytes)

You can use the caption field as your “ugly” title, and the title will be used to set the permalink.

Demo : https://demos.tiddlyhost.com/#short-link

5 Likes

I have looked at this issue before and ultimately realised the easiest way to having a tidy url is to have a simple tiddler name. Once someone arrives in your wiki you can show or do anything you want. In fact if you are going out of your way to capture a link “into a wiki and directly to a tiddler” then we can make use of this fact.

Here is a simple example;

  • On tiddlywiki.com create a tiddler " customise-favicon"
  • Place this inside the tiddler {{Setting a favicon}}
  • Save and copy the permalink https://tiddlywiki.com/#customise-favicon
    • which is nicer than the original https://tiddlywiki.com/#Setting%20a%20favicon

This whole concept can be taken a lot further for example

  • a button on any tiddler that allows you to create an alternate tiddler that transcludes it, the source tiddler
  • Add a redirect-caption identical to the source tiddler title
  • When the redirect-caption field exists use that rather than the title in the view template, using the Cascade - View Template title.

The user will not know they are in anything but the the alternative tiddler unless they edit it.

  • Even then we could modify the buttons to detect the source tiddler and have the buttons act on it instead. - this may be automated.

It is interesting how the language we adopt can influence how we see things later. Sometimes it throws a light on new things other times it distracts us from new ways. For example what I describe above could be called a shadow tiddler, but this term is already defined as something else.

  • Another, even better technique may be to alter the missing tiddler template to look for the missing tiddler title in other tiddlers and do similarly to above, to make a missing tiddler look like a real tiddler.

Finally;

  • Of course another way to deal with this is if you are generating Static tiddlers you can alter the naming rules of the static tiddlers you export and share their link rather than the permalink.
  • As I discuss here, this can be achieved by altering the template used to generate static tiddlers and could use a method including and similar to How to export static tiddlers who's internal links will open the master wiki

[update] I have developed an “alternative title” and 80% of “tiddler masquerade” solution. I will post elsewhere and link to it sone.

Wow! I was putting off testing the idea, thinking it will take me hours to figure out the required customization of the view template. But you implemented in mere two lines. :clap:

I think we can expand this idea to get rid of Relink plugin. If the title of the tiddler is always a unique number, UUID, then we will not need Relink plugin to perform renaming because the user will not need to edit the title field.

Each tiddler always gets a unique title, which does not need to be renamed. The human-readable title is a caption or some other field, say my-title. When linking tiddlers, you connect via the UUID.

There will be issues, though, because TW is not designed to use the title field this way.

One obvious place where it breaks down is the search box. So you need a custom search field that should use your custom field, my-title instead of searching the’ title’ field.

1 Like

For my personal wikis I generally use tiddler titles: like-this-one. My tiddler titles are always “all lowercase” and combined with hyphens between every word.

I do use the unilink-plugin alias function to be able to use different tiddler pretty-links for the same tiddler title.

There are several advantages:

  • TW core permalinks are always human readable out of the box
  • Together with the slant-01 theme I can use headings inside the tiddler text instead of the tiddler title.
  • I put much effort in tiddler names from the start. So it shouldn’t be needed to rename them.
  • Since links use aliases, it doesn’t matter if titles are renamed
    • But - I still include the relink-plugin in my wikis, if I need to rename titles.
  • I use the “caption” field for short titles to be displayed in tabs
  • I use the “subtitle” field if I need longer tiddler titles
  • aliases are usually short to create short links like [[so|?]], so it doesn’t matter if tiddler titles are complex

Just some thoughts, to be able to use the core permalink function with human-readable-titles.

2 Likes