Skip to main content

The PreTeXt Guide

Subsection 29.1.1 index.html Page

The conversion to HTML always creates a file named index.html. We do this because if a reader requests the URL
platypus.mammal-institute.org/aota/html
then most modern web servers will automatically return the page
platypus.mammal-institute.org/aota/html/index.html
So you can advertise the shorter version to potential readers. What is in index.html? Simple code to redirect to another one of your pages. Which one? Any one you like!
Within the <publication> element of your publication file (Section 26.1) include an <html> element, with a child element <index-page> having an attribute @ref. The value must be the @xml:id of a division which is rendered as an entire web page at the requested level of chunking. See Subsection 44.4.6 for details on specifying this option.
For example, if a <book> is being chunked into <chapter>, and your source has
<chapter xml:id="birds">
then you can set ref="birds" and the page for that chapter will be the default page for the shorter URL. In practice, you probably really want a page that looks like the front matter or a Table of Contents.
The default is to first have index.html redirect to a page for the <frontmatter>, and if this is not possible, then it will redirect to a page for the top-level of your content. If your document is short or simple, you may just have a single web page. You could choose to not distribute the index.html file and then just use a concise and descriptive @xml:id for your top-level element (e.g. <article>) to fashion an attractive URL that points to your shorter work.