5

If I go TiddlyWiki site I can see tab Content. How can I create my own table of content for my tiddlywiki file?

YakovL
  • 5,213
  • 10
  • 46
  • 71
lowtech
  • 2,233
  • 1
  • 19
  • 30
  • Youtuber does exactly that in this video: https://www.youtube.com/watch?v=bu7JU4DjPrg&list=PLzZCajspPU_UjFn0uy-J9URz0LP4zhxRK&index=2 – Bob Feb 29 '20 at 22:58

3 Answers3

6

I found the documentation for this really confusing, but here's what I did that works best:

<div class="tc-table-of-contents">

<<toc-selective-expandable 'TableOfContents' sort[ind]>>

</div>

Then, tag each tiddler with TableofContents.

Lastly, when editing each tiddler, add a new field named "ind" (for index - you can change this to whatever you like, so long as it's not being used elsewhere, of course). Assign a value to "ind" starting with 0 to tell it what order you want the tiddlers to go in. I incremented by 10 instead of 1 in case I want to rearrange a few things or insert more in the middle.

Andrew
  • 3,330
  • 1
  • 33
  • 53
5

Create a new tiddler and give the title Contents

Under tags, give the value $:/tags/SideBar

Under type the text for this tiddler, give <$list filter={{$:/core/Filters/AllTiddlers!!filter}} template="$:/core/ui/ListItemTemplate"/>

Shankar Rajan
  • 110
  • 2
  • 7
  • This is great - it works in my firefox on windows, TiddlyWiki 5.1.9. Many thanks for your answer. – lowtech Mar 28 '16 at 16:11
3

This is explained in the documentation.

The short version: Add some tag (e.g. Content) to the pages you want to appear in the TOC; then in the place where you want it to appear, use one of the macros with that tag name (e.g. <<toc Content>>). To make a nested TOC, tag pages with the names of tags that appeared at the top level. So for example if you have a tiddler named First that is tagged with Content, then you can tag more tiddlers with First, and they will appear indented below First in the TOC.

Karl Knechtel
  • 51,161
  • 7
  • 77
  • 117
  • The docs are a bit confusing. I am looking to generate a table of contents within a given tiddler that's very long: e.g. for its own h1s, h2s, etc. Do you know of a way to generate a table of contents for the hierarchy like this *within a single tiddler for that single tiddler itself*? Edit: It sounds like this may not be possible :( according to https://groups.google.com/g/tiddlywiki/c/5rosst5JqTU. – Taylor Edmiston Jan 28 '21 at 02:00
  • I don't think I understand the question. A tiddler with a table of contents... "for the tiddler itself"? As in, it lists exactly one item, which is itself? What use is that? – Karl Knechtel Jan 28 '21 at 05:42
  • As in it lists an outline of the hierarchy of that tiddler. Like what a table of contents extension in Markdown does. Example: https://python-markdown.github.io/extensions/toc/. – Taylor Edmiston Jan 31 '21 at 16:56
  • I don't know a way to do that, but I would suggest that it's not how tiddlers are meant to be used anyway. Try putting less text on each; you'll be happier in the long run, since you'll have more opportunities to, e.g. make useful cross-references, include sections in categories, etc. – Karl Knechtel Feb 03 '21 at 14:43
  • That approach unfortunately doesn't scale super well for this use case. (It's hundreds of one line items that change frequently through bulk editing.) – Taylor Edmiston Feb 03 '21 at 18:31