Import Script: Standalone

import-in-standalone.sh publishes a Maven site generated with the StILi skin as self-contained, standalone HTML pages — no framework or build step required.

Prerequisites

  • bash
  • jq (JSON processor)

Usage

Run the script from the Maven site output directory (target/site/):

bash target/site/import-in-standalone.sh <WEBROOT> [OPTIONS]

<WEBROOT> is the document root of your web server (e.g. /var/www/html).

Parameters

Parameter Description
<WEBROOT> Path to the web server document root (required).
--base <path> URL prefix prepended to all generated URLs. With --current: URL becomes /<base>/<project>/. With --archived: /<base>/<project>/<version>/. Also prepended to explicit <url> given to --current/--archived. Default: none (project at root).
--project <name> Overrides the project name derived from artifactId.
--stylesheet <url> URL of a stylesheet to link in every page's <head>. May be specified multiple times for multiple stylesheets. Replaces the default css/site.css link.
--bootstrap Link Bootstrap 6.0.0-alpha.1 from jsDelivr CDN and apply Bootstrap-compatible markup enhancements. See Bootstrap below.
--docker Write docker-compose.yml and nginx.conf to <WEBROOT>. See Docker Development Server below.
--current [<url>] (Default) Marks this version as the current (visible) release. If <url> is given, it replaces <project> in the URL: /<base>/<url>/.
--archived [<url>] Marks this version as archived. Each page gets a <link rel="canonical"> pointing to the corresponding current-version page. If <url> is given, it replaces <project>/<version> in the URL: /<base>/<url>/.
--canonical <url> Explicitly sets the canonical URL base written to <link rel="canonical">. Not affected by --base. With --archived: defaults to <base>/<project> if not given. With --current: canonical link only emitted when this flag is given. Valid with both --current and --archived.
--clean-only Remove the output directory created by a previous import and exit without publishing. Mutually exclusive with --no-clean.
--no-clean Skip cleaning the output directory before publishing. Mutually exclusive with --clean-only.

Only one of --current and --archived may be specified.

What the Script Produces

HTML pages

Each .html page from the Maven site output is wrapped in a complete HTML document and written to <WEBROOT>/<base>/<project>/ (current) or <WEBROOT>/<base>/<project>/<version>/ (archived):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Page Name &#x2013; Project Name</title>
  <link rel="stylesheet" href="css/site.css">
  <!-- <link rel="canonical" ...>  (only for --archived or explicit --canonical) -->
</head>
<body>
  <h1 id="stili-title">Page Name</h1>
  <div id="stili-breadcrumbs">&#x2026;</div>
  <div id="stili-body">&#x2026;</div>
  <div id="stili-menu">&#x2026;</div>
  <script id="stili-json" type="application/json">&#x2026;</script>
</body>
</html>

The stili-json block is kept intact in every page for downstream use.

Title format:

Page Title
index.html (current) Project Name
index.html (archived) Project Name (version)
any other page Page Name – Project Name

For archived index.html, the version is also appended to the visible <h1> heading.

Static assets

All subdirectories (e.g. css/, img/) are copied alongside the HTML pages into the output directory.

CSS and Styling

By default, the script links css/site.css (relative to each page). This file is copied from the Maven site output alongside the other assets. It initially contains only a comment and can be used to add custom styles:

/* You can override this file with your own styles */

To use a different stylesheet (or multiple stylesheets) instead:

bash target/site/import-in-standalone.sh /var/www/html \
    --stylesheet /static/my-theme.css

Specify --stylesheet multiple times to link multiple files. When at least one --stylesheet is given, the default css/site.css link is not added — only the explicitly specified stylesheets are linked.

Bootstrap

--bootstrap adds a complete Bootstrap 6.0.0-alpha.1 setup to every generated page:

What gets added to <head>:

<!-- before any --stylesheet links -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/css/bootstrap.min.css">

<!-- at end of <head>: adds class="table" to all tables in stili-body -->
<script>document.addEventListener("DOMContentLoaded",function(){
  document.querySelectorAll("#stili-body table").forEach(function(t){
    t.classList.add("table")
  })
});</script>

What gets added to <body>:

<body>
  <div class="container py-3">
    <!-- StILi content (h1, breadcrumbs, body, menu, stili-json) -->
  </div>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/js/bootstrap.bundle.min.js"></script>
</body>

Breadcrumb markup (rendered by Maven, active for all outputs):

The stili-breadcrumbs element already uses Bootstrap's breadcrumb component classes, so breadcrumbs render correctly out of the box without post-processing:

<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="...">Root</a></li>
    <li class="breadcrumb-item active" aria-current="page">Current Page</li>
  </ol>
</nav>

Tables in stili-body get class="table" added at runtime by the inline script, picking up Bootstrap's table styling without requiring any change to the Maven content.

Further customisation via css/site.css (default) or --stylesheet:
Bootstrap CSS is linked first, so any subsequent stylesheet can override or extend it.

Docker Development Server

--docker writes two files directly into <WEBROOT>:

Both files are copied from the Maven site output (they are shipped as Maven resources alongside the script itself):

  • docker-compose.yml — starts an nginx:1.22 container on port 8888
  • nginx.conf — serves the <WEBROOT> tree as static files

The container mounts the entire <WEBROOT> as its document root, so all published projects are accessible at their real URL paths:

bash target/site/import-in-standalone.sh \
    /tmp/webroot \
    --base /docs \
    --docker

cd /tmp/webroot
docker compose up
# &#x2192; http://localhost:8888/docs/my-project/

Because nginx serves the full <WEBROOT> tree, the relative css/site.css links in the HTML pages resolve correctly regardless of how deeply the project is nested.

--docker can be repeated across multiple import-in-standalone.sh runs without conflict — the files are simply overwritten with the same content.

URL Defaults

Mode Output path URL base
--current, no --base <webroot>/<project>/ /<project>/
--current --base /path <webroot>/path/<project>/ /path/<project>/
--current <url>, no --base <webroot>/<url>/ /<url>/
--current <url> --base /path <webroot>/path/<url>/ /path/<url>/
--archived, no --base <webroot>/<project>/<version>/ /<project>/<version>/
--archived --base /path <webroot>/path/<project>/<version>/ /path/<project>/<version>/
--archived <url>, no --base <webroot>/<url>/ /<url>/

Examples

Publish the current release directly under the document root:

bash target/site/import-in-standalone.sh \
    /var/www/html

Publish an archived version under /docs/my-project/<version>/ with a canonical link pointing to the current version:

bash target/site/import-in-standalone.sh \
    /var/www/html \
    --base /docs \
    --archived \
    --canonical /docs/my-project

Publish an old version at a historically-used URL (e.g., /my-project-2.0.0/):

bash target/site/import-in-standalone.sh \
    /var/www/html \
    --archived /my-project-2.0.0

The auto-computed canonical will point to /<project>/ (the current version's URL).

Publish with a custom stylesheet:

bash target/site/import-in-standalone.sh \
    /var/www/html \
    --stylesheet /assets/theme.css

Publish and set up a local development server:

bash target/site/import-in-standalone.sh \
    /tmp/webroot \
    --base /docs \
    --docker

cd /tmp/webroot && docker compose up