Render all pages of a site

Hello,

I have a Hugo website that I use for documentation.
I would like to users to be able to print the full documentation at once.

I am looking to render all the pages and generate one HTML. Anyone has already done that?

Thanks

You can render any page collection on whatever HTML page with:

1 Like

Grouped by first-level section, then sorted by page title, this displays the .Title and .Content of each page.

layouts/_default/list.html (or some other list template)

{{ range site.Sections.ByWeight }}
<h1>{{ .Title }}</h1>
{{ range .RegularPagesRecursive.ByTitle }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ .Content }}
{{ end }}

Seems simple enough, but take this example:

content
β”œβ”€β”€ books/
β”‚   β”œβ”€β”€ book-1.md
β”‚   β”œβ”€β”€ book-2.md
β”‚   └── _index.md
└── films/
    β”œβ”€β”€ film-1/
    β”‚   β”œβ”€β”€ index.md  <-- contains markdown ![Poster](poster.jpg)
    β”‚   └── poster.jpg
    β”œβ”€β”€ film-2.md
    └── _index.md

In the absence of an image render hook that rewrites the image src attribute for portability, the β€œposter” image will be broken when we render films/film-1/index.md. The image will be broken because the src attribute is relative to film-1.

The same is true for links.

Additionally, without a heading render hook to create globally unique heading id attributes, link fragments (example: [list of actors](#actors)) in your markdown may have an indeterminate target. For example, taking the content structure above, it is likely that each film will have the same headings, for example:

### Actors

### Awards

### Plot

There are similar challenges with code block line anchors, footnotes, etc.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.