Skip to main content

The PreTeXt Guide

Section 29.10 Single Page HTML

Sometimes you would like a shorter work to be a single file in HTML format. Perhaps it is something self-contained, like a course syllabus, or you desire to attach it easily to an email or other post. This section contains advice and procedures you can use to achieve this.
The primary mechanism for limiting the number of files in an HTML build is to set the @portable attribute of publication/html/platform to "yes" (see Subsection 44.4.11). This will automatically take care of the following.
  • Use hosted (CDN) versions of the CSS and javascript files rather than including them in your output directory.
  • Embed generated SVG images in the HTML (anything from <prefigure> or <latex-image>).
  • Embed the search code in the HTML (if you are using the )
  • Set all xref knowls to behave like links (same as setting /publication/html/cross-references/@knowled to never).
  • Produce a single file will all your chapters/sections/subsections in it (the same as setting /publication/common/chunking/@level to 0).
  • Prevent the generation of most extra “standalone” pages (such as for most interactive elements and worksheets).
  • Not produce the standard index.html file that is otherwise used to redirect to the main page.
Keep in mind that if your document has external assets, or uses generated assets that are not converted to SVG, these assets will still be needed in your output (regardless, you will get external and generated directories for your assets, but these might be empty or not needed). Additionally, some interactive elements work by creating an iframe that loads an HTML file, and these cannot be avoided currently.
Finally, depending on the purpose of your document, you might consider using a simpler theme. The boulder theme is designed to look like a -produced PDF; it doesn’t have any masthead, which makes sense for a single page document. Other style options are described in Section 29.6.
For very small documents, you might also consider turning off the table of contents by setting /publication/common/tableofcontents/@level to 0 (see Subsection 44.1.2).