Antora Demo

You don’t need to set up a docs component or create a UI to try out Antora.
We’ve set up a playbook file, several content source repositories, and provided a default UI bundle.
As soon as you’ve installed Antora, you can run Antora with the Demo materials and explore its capabilities.
The instructions and examples on this page will show you how to operate Antora with the Demo materials.

Choose a Playbook

To produce a documentation site, Antora needs a playbook.
But first, you’ll need to create or choose a directory where you’ll store the playbook and where the generated site files will be saved (assuming you use the default output configuration).

For the examples on this page, we’ll use the Demo materials.

Open a terminal and make a new directory named demo-site.

~ $ mkdir demo-site

Switch (cd) into the directory you just made.

~ $ cd demo-site

Using your preferred text editor or IDE, create a new playbook file named site.yml and populate it with the contents of the following example.
You can also download the Demo site playbook from the Demo repository.

Once cloning is complete, Antora converts the AsciiDoc pages to embeddable HTML, wraps the HTML in the UI page templates, then assembles the pages into a site under the destination folder, which defaults to build/site.

Antora has completed generation when the command prompt ($) reappears in the terminal.

If something goes wrong during generation, you’ll see an error message in the terminal.

error: a message that summarizes what went wrong

If this message does not provide enough information to fix the problem, you can ask Antora for more context.
To tell Antora to reveal the calls leading up to the error (i.e., the stacktrace), run the antora command again, this time with the --stacktrace option:

The 404 page and sitemap files will be missing if the site.url property is not defined in your playbook.

This list includes the entry point of your documentation site, index.html.

On some operating systems, you can open the site directly from the command line by typing open, followed by the name of the HTML file.

site $ open index.html

Or, you can navigate to an HTML page inside the destination folder in your browser.
If you’ve been following along with the Demo materials, once you find the demo-site directory, navigate to the file build/site/index.html.

Cache

When Antora runs the first time, it will cache resources in a cache directory.
Antora caches two types of resources:

cloned git repositories

downloaded UI bundles

These resources are stored inside the cache directory, organized under the content and ui folders, respectively.
The default cache directory varies by operating system.
You can override the default cache location using the runtime.cache_dir key in the playbook, the --cache-dir CLI option, or the $ANTORA_CACHE_DIR environment variable.

If you want to update the cache on subsequent runs, pass the --pull switch to the Antora CLI.
This switch will force Antora to run a fetch operation on each repository it previously cloned.
It will also force Antora to download a fresh copy of the UI bundle, if remote.

If you want to clear the cache altogether, you’ll need to locate the Antora cache directory on your system and delete it.

Private git repositories

Antora supports connecting to private repositories using SSH or HTTP/HTTPS.

If your playbook is configured to fetch private repositories via SSH, you must run an SSH agent with the identity (i.e., SSH key) you’ve linked to your account on the git host.
If the SSH agent isn’t running, or your key and account don’t match, Antora will fail when it attempts to clone the private repository.

Local Site Preview

Since Antora generates static sites, you do not need to publish the site to a server in order to preview it.

To view the site, navigate to any HTML page inside the destination folder in your browser.
If your using the Demo, look for the file /demo-site/build/site/index.html.

Optional: Run local server

A site generated by Antora is designed to be viewable without a web server.
However, you may need to view your site through a web server to test certain features, such as indexified URLs or caching.
You can use the serve package for this purpose.

Install the serve package globally using npm:

demo-site $ npm i -g serve

That puts a command by the same name on your PATH.
Now launch the web server by pointing it at the location of the generated site.
In the terminal, type serve build/site.
After executing the command, a the local address should be displayed in your terminal.

Paste the provided URL into the location bar of your browser to view your site through a local web server.

Press Ctrl+C to stop the server.

Publish to GitHub Pages

Antora is designed to create sites that run anywhere, whether it be a static web host or the local filesystem.
However, some hosts offer “features” that interfere with Antora’s output.
GitHub Pages is one of those hosts.

By default, GitHub Pages runs all files through another static site generator named Jekyll.
Since Antora already produces a ready-made site, there’s no need for this.
It’s also problematic since Jekyll has the nasty side effect of removing all files that begin with an underscore (_).
Antora puts UI files in a directory named _, which Jekyll subsequently erases.
As a result, no UI.
Antora also puts images in a folder named _images inside each module, so no images either.

Fortunately, there’s a way to disable this “feature” of GitHub Pages.
The solution is to add a .nojekyll file to the root of the published site.
Simply create an empty .nojekyll file in the output directory before committing the files to GitHub Pages.

$ touch build/site/.nojekyll

The presence of the .nojekyll file at the root of the gh-pages branch tells GitHub Pages not to run the published files through Jekyll.
The result is that your Antora-made site will work as expected (and will be available sooner).