Partials, Examples and Attachments
|
This content was generated with the assistance of AI and should be verified against the official documentation of each tool before being relied on in production. This section’s bibliography lists the reference material consulted while preparing these pages. |
Besides pages and images, a module can hold three more families of files: partials, examples and attachments. Partials are reusable AsciiDoc fragments, examples are source files that pages quote, and attachments are files that visitors download. This page explains how each family is stored, referenced and published. It was written against Antora 3.2.1 and checked on 2026-10-26. The examples use Pocket Units, a tiny units-conversion library, and were built with Antora 3.2.1 and the Antora Default UI from a local Git repository.
The families live in sibling directories of a module, as described in modules and families:
modules/ROOT/
attachments/
units.csv
pocket-units-sample.zip
examples/
convert.cs
csharp/convert.cs
pages/
partials/
install-note.adoc
Partials
A partial is a file in the partials directory. It is not published as a page: its content appears on the site only
when a page, or another resource included by a page, includes it. Editing a partial changes every page that includes it
at the next build. Typical uses are warnings, terminology, reference tables and navigation lists (see
Navigation). The official guidance is to avoid spaces and uppercase
letters in file names and to use the .adoc extension for AsciiDoc fragments.
Including a partial
Use the include:: directive with the partial$ family. The file coordinate is the path inside partials.
Install {product-name} with `dotnet add package PocketUnits --version 2.0.0`.
= Getting Started
:reftext: Quick start
[#install]
== Install
include::partial$install-note.adoc[]
Source: Antora docs: Include a partial
The directive must start a line. Surround it with blank lines to get a standalone block, or put it directly against
other lines to attach the content to a block. The partial is converted after insertion in the context of the including
page, so {product-name} was taken from the asciidoc.attributes of antora.yml, and the built page shows "Install
Pocket Units with dotnet add package PocketUnits --version 2.0.0". If a partial sets an attribute, the attribute is
available in the page from that point and overrides a same-named attribute of the page header or the descriptor.
Partials with headings
A partial may contain section headings. The leveloffset attribute shifts them to fit the place of the directive. With
leveloffset=+1, a partial whose title is = Shared Heading was rendered as a level-two section:
include::partial$section.adoc[leveloffset=+1]
Partials in other modules and components
The default family of an include is page$, so the family is always required. Other modules and components are reached
by adding coordinates to the resource ID, like in xrefs (see
resource IDs and xrefs):
include::guides:partial$install-note.adoc[]
include::2.0@pocket-units:ROOT:partial$install-note.adoc[]
include::2.0@pocket-units::partial$install-note.adoc[]
Source: Antora docs: Include a partial
The first line names another module of the same component version, the second a module of another component version and
the third the ROOT module of that version, which can be omitted although the colon stays. Without a version Antora
uses the latest version of the target component. Xrefs, images and nested includes inside a partial are resolved against
the page that includes it, so write them with coordinates valid in every including context. These forms are taken
from the official documentation and were not all built here; the unqualified forms were.
Examples
The examples directory holds files that pages show as listings: source code, configuration, sample output. Keeping
them as real files lets you compile or run them and quote only the relevant part. A file in a subdirectory needs its
path relative to examples, for example csharp/convert.cs.
using PocketUnits;
// tag::usage[]
double miles = Converter.Convert(10, LengthUnit.Kilometre, LengthUnit.Mile);
// end::usage[]
// tag::print[]
Console.WriteLine(miles);
// end::print[]
The tag markers are ordinary comments in the language of the example. Asciidoctor removes the lines that carry a marker whenever tags are selected.
Selecting tags
Select a region with tag and several regions with tags, separated by semicolons. The regions are concatenated in
the order they appear in the file.
[source,csharp] ---- include::example$convert.cs[tag=usage] ----
The built result of tag=usage contained only the conversion line. With tags=usage;print it contained the two
lines one after the other with the marker lines removed, and the using line and the blank lines were left out:
double miles = Converter.Convert(10, LengthUnit.Kilometre, LengthUnit.Mile);
Console.WriteLine(miles);
Source: Antora docs: Include an example
The syntax of tag, tags and lines is the Asciidoctor one. The Antora page refers to the Asciidoctor documentation
instead of repeating it.
Selecting lines
lines takes line numbers and ranges, separated by semicolons (commas need quotes around the value). lines=1;4..5 includes line 1 and the
lines 4 to 5. Lines are counted in the example file, and unlike tags, they keep any tag marker lines that fall inside the
range: the build of lines=1;4..5 ended with the // end::usage[] comment, which is not what you want in a listing.
Prefer tags, which survive edits of the file, and use line ranges only for files you do not control, such as a
generated file.
[source,csharp] ---- include::example$csharp/convert.cs[lines=1;4..5,indent=0] ----
The indent attribute rewrites the left margin of the included lines. indent=0 removes common leading whitespace,
which is useful for a method body taken from a class. It was set in the example above but made no difference, because
the lines were not indented.
Examples from other modules and versions
include::ROOT:example$convert.cs[tag=print]
include::pocket-units:guides:example$timer.cs[]
include::2.0@pocket-units::example$convert.cs[]
Source: Antora docs: Include an example
The first line was built. The other two follow the forms of the official documentation and were not executed here. Without a version Antora includes the latest version of the component when the target is in another component.
Errors
When the family is missing, the include falls back to page$ and cannot find the file:
include::convert.cs[]
Source: Antora docs: Include an example
The page build logged the error target of include not found: convert.cs and the page showed the text "Unresolved
include directive in modules/ROOT/pages/experiments.adoc - include::convert.cs[]" in place of the listing.
Showing an include directive in a listing
An include:: line inside a listing block is still processed. To show the directive itself, as this page does, put a
backslash in front of it. The built page shows the line without the backslash. A listing that itself contains a ----
line must be delimited by .... instead.
Attachments
An attachment is a file that visitors download or open: a PDF, a ZIP archive, a CSV file. Attachments live in the
attachments directory of a module and are published unchanged, but they are not pages and are not converted. In the
built Pocket Units site they were written to the _attachments folder of the component version, for example
pocket-units/2.0/_attachments/units.csv.
Linking to an attachment
Use the xref macro with the attachment$ family. Without the family Antora treats the target as a page.
Download the xref:attachment$units.csv[unit table] or the xref:attachment$pocket-units-sample.zip[sample project].
The generated links were <a href="_attachments/units.csv" class="xref attachment">unit table</a> and the same for
the archive. A fragment cannot be added to an attachment resource ID. Attachments have no default reference text. If
the brackets are empty Antora shows the resource ID, as in attachment$pocket-units-sample.zip, so always give a text.
Whether the browser downloads the file or displays it depends on the file type and the browser settings.
Source: Antora docs: Attachments
Attachment links can also be used in navigation files, as shown in Navigation. Other modules and versions are reached the same way as for the other families:
xref:guides:attachment$units.csv[Unit table]
xref:2.0@pocket-units:ROOT:attachment$units.csv[Unit table of 2.0]
xref:2.0@attachment$units.csv[Unit table of version 2.0]
Source: Antora docs: Attachments
These forms are given in the official documentation. They were not built here.
Choosing between the families
| Family | Content and conversion | Reached with |
|---|---|---|
|
AsciiDoc fragments, converted in the context of the including page |
|
|
Any text file, shown as a listing; can be tagged and compiled |
|
|
Binary or text files published unchanged |
|
|
Images, referenced with the |
|
Pitfalls
-
Forgetting the family (
include::convert.cs[]) gives an unresolved include, because the default family ispage$. -
Line ranges include tag markers that sit inside the range. Prefer tags.
-
A partial is converted in the context of the including page, so attributes, relative xrefs and image names must be valid there.
-
An empty xref text on an attachment shows the resource ID.
-
Attachments are not checked for use: a file nobody links to is still published.