Building an Org Mode Website: Part 7 - Index Pages

Index Pages

In order to have a 'tag-like' capability 1 I next turn on the index feature on the website. By setting the 'makeindex' parameter to non-NIL, the publishing backend will create an index of any pages that have an index parameter set. The makeindex parameter will look like this in your org-publish-project-alist project:

("org-blogs"
 :base-directory "./blogs"
 :publishing-function org-publish-attachment
 :recursive t
 // ...
 :makeindex t
 // ...
 )

For each file that you want included in the index you need set a file variable in the file header section like this:

#+title:      Building an Org Mode Website: Part 7 - Index Pages
#+index:      Emacs

The problem with this approach is that the publishing function will create a link for every file with an index parameter set, but the title of the link will also just be 'Emacs' in this example. There is no way for the reader to distinguish between verious links with the same index value. To work around this, the index feature also supports a hierarchial structure for the index files. Each level just needs be separated with a '!'. Using this, you can specify how you want the index entry to look. An example:

#+title:      Building an Org Mode Website: Part 7 - Index Pages
#+index:      Emacs!Building an Org Mode Website: Part 7 - Index Pages

With this example, the makeindex function will create a index heading for 'Emacs' and then create sub-entries using the text after the exclamation point. This is not exactly a true 'tag-like' feature, but it gets close to providing a similar effect.

Customizing the Index Page

The first time the makeindex function is run for a project, it will create a 'theindex.org' file in the project directory. The initial version of the file will look like this:

#+TITLE: Index

#+INCLUDE: "theindex.inc"

The index itself is generated in the 'theindex.inc' file. You can customize the org file before and after the include entry as desired. You can also place the '#+INCLUDE' line in a different file if you want to have a different name for the file. You can also use the 'EXPORTFILENAME' variable to customize the filename that is generated by the publishing function. There does not appear to be any way to customize the makeindex function, so it will always recreate a 'theindex.org' if there is not one.

Footnotes:

1

Meaning the tag feature that is available on most common blogging platforms where they create pages with links to every post with the same tag; not sure if there is a way to use Org Mode tags in achieve a similar effect