Define and Modify Attributes
Let’s activate the AsciiDoc attribute named
The attribute is set by entering its name in an attribute entry in the header of the page.
= Page Title :sectanchors: (1)
|1||The attribute is set in page header by directly preceding its name,
In the next example, let’s assign a value to a built-in AsciiDoc attribute.
xrefstyle has three built-in values it can accept,
= Page Title :xrefstyle: short (1)
short value is assigned to
xrefstyle, any in-page references to blocks with anchors will display the blocks’ label and number, e.g., Listing 1, if no link text is specified in the reference.
Some built-in AsciiDoc attributes are not applicable in the Antora environment.
These attributes include
Custom attributes often store frequently used text and URLs. They’re then referenced throughout the page by simply entering their name (instead of repeatedly typing the text or URLs). Before they can be referenced, custom attributes must have a user-defined name and be assigned a value.
The attribute’s name must:
be at least one character long,
begin with a word character (A-Z, a-z, 0-9, or _), and
only contain word characters and hyphens.
The name cannot contain dots (
.) or blank spaces.
Although uppercase characters are permitted in an attribute name, the name is converted to lowercase before being stored. A best practice is to only use lowercase letters in the name and avoid starting the name with a number.
Attribute values can:
be any inline content, and
contain line breaks, but only if an explicit line continuation (
+) is used.
= Page Title :url-repo: https://gitlab.com/antora/demo/docs-site
Now, you can reference the attribute wherever needed throughout the page by entering its name inside a set of curly braces (
You can see another example of a custom attribute being used to replace a complex URL in Create an attribute for a URL.