There are debates over whether indexing is still needed. Print books still need them to find contents. However, many digital books include full text search and this caused some to argue that indexes are no longer needed. I think they help readers.
With the free tools I’m recommending you’ll only get a back-of-the-book index for PDF because its intended for printing to paper books. There are other free tools like the DocBook chain of XML tools, but that requires a skill level you may not want to work to achieve, so I’ll leave that out. Just know that if you must include an index for eBooks you’ll need to use DocBook’s approach.
There are two ways of adding index entries.
1. indexterm:[primary, secondary, tertiary] (1) 2. (((primary, secondary, tertiary))) (2)
This type of index entry only shows up in the index, not in the book content.
This type of index entry shows the text inside to the reader in the content and in the index.
Here is an index entry example from this book.
Often nonfiction books need a glossary. AsciiDoc makes it easy to ((add a glossary)). (1)
This primary index entry is inline and the text inside is both rendered for the reader and added to the index for PDF. You know its a primary entry because there are no other index entries inside the double parentheses separated by commas.
For people not familiar with indexing conventions, sometimes one index entry has several subentries.
table adding rows adding columns spanning cells
To accomplish this in AsciiDoc, you would need to use primary and secondary entries. See the following example.
Let's talk about how to make table rows. indexterm:[table, adding rows]
The rendering app, AsciiDoctor, takes these inline index entries and adds a page number in the index for wherever the page this content shows up. Having the tool automatically generate an index entry frees the author to not worry about such things as long as the index entries are formatted correctly.
The primary index entry is table in the preceding example. One of the secondary index entry is "adding rows", which typically is indented under the primary entry.
It is important to get all the primary entries correct or you’ll have a messy index. For this reason, many indexes include mostly primary index entries only. That is the case with this book.