rmfberlin
rmfberlin

Reputation: 33

How to insert different adoc files into another adoc file using HUGO

I would like to merge various asciidoc files into one main document for a comprehensive documentation. In AsciiDoctor this is no problem with e.g. include::chapter01.adoc[tag=main].

However, this does not work directly with HUGO. I have found the following shortcode:

{{ $file := .Get 0 }} {{ (printf “%s%s” .Page.File.Dir $file) | readFile | replaceRE “^---[\\s\\S]+?---” “” | safeHTML }}

Source: Including content from external links with Asciidoc in Hugo

This works in HUGO to the extent that the entire adoc file is read in and rendered correctly. But also with the AsciiDoctor-specific header. However, with this shortcode I cannot use [tag=main] to read only certain parts of the chapter01.adoc.

How do I have to adapt this shortcode or write it completely differently?

include:: works in AsciiDoc, but not in HUGO, as does'nt xref; xref tries to reference an HTML file that does not exist.

Upvotes: 0

Views: 86

Answers (1)

eskwayrd
eskwayrd

Reputation: 4521

According to the Hugo documentation, AsciiDoc include macros should work. You may have to set workingFolderCurrent in your Hugo config, and then use an appropriate relative path to the included file.

Upvotes: 0

Related Questions