Render all pages of a site


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?


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:

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

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/ 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.


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