Theming the Index

The public directory index is rendered by Go from an embedded theme: a layout, an index template, an error template, a sign-in template and a few assets. Point VELA_THEME_DIR at a directory and any file you put there replaces its built-in counterpart.

The default theme

The built-in theme is responsive, follows the system light/dark preference, uses no JavaScript and no external resources, and shows file-type icons, sizes and dates. Directories come first, then files, both sorted naturally and case-insensitively (file2 before file10). Only public, unexpired files appear — unless the visitor has signed in, in which case they also see what their key can reach, marked with visibility indicators.

Overriding files

theme/
├── layout.html        # defines "layout": the page shell
├── index.html         # defines "content" for directory pages
├── error.html         # defines "content" for 404 / 410 pages
├── login.html         # defines "content" for the web sign-in page (v0.3+)
└── assets/
    ├── style.css
    ├── favicon.svg
    └── favicon.ico
  • Partial overrides are fine: a missing file falls back to the embedded version.
  • New assets can be added — fonts, images, extra stylesheets — under assets/.
  • Templates are parsed and sample-rendered at startup. An invalid template or a reference to a missing asset stops the server with a clear error.
  • Changes require a restart.

Start from the reference templates in the repository at internal/index/theme/. Mount your directory read-only and point the setting at it:

docker run -d --name vela … \
  --mount type=bind,src=/etc/vela/theme,dst=/theme,readonly \
  -e VELA_THEME_DIR=/theme \
  xchunk/vela:0.9.0

Templates

layout.html defines a template named layout; index.html, error.html and login.html each define content. Each page type is parsed together with the shared layout. The embedded layout also offers a title block. Templates use Go's html/template, so everything is escaped by context — object names and metadata are untrusted text.

{{define "layout"}}<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{if .NoIndex}}<meta name="robots" content="noindex, nofollow">
{{end}}<title>{{block "title" .}}{{.Site.Title}}{{end}}</title>
<link rel="stylesheet" href="{{asset "style.css"}}">
<link rel="icon" href="{{asset "favicon.svg"}}" type="image/svg+xml">
</head>
<body>
<header>
  {{if .RootDisabled}}<span class="brand">{{.Site.Title}}</span>
  {{else}}<a class="brand" href="/">{{.Site.Title}}</a>{{end}}
</header>
<main>{{template "content" .}}</main>
<footer>Served by Vela {{.Version}}</footer>
</body>
</html>
{{end}}
{{define "content"}}
<nav class="crumbs">
  {{range .Breadcrumbs}}
    {{if .URL}}<a href="{{.URL}}">{{.Name}}</a>{{else}}<span>{{.Name}}</span>{{end}}
  {{end}}
</nav>
{{if .Description}}<p class="lede">{{.Description}}</p>{{end}}
<ul class="listing">
  {{if .Parent}}<li><a href="{{.Parent}}">{{icon "parent"}} ..</a></li>{{end}}
  {{range .Dirs}}
    <li><a href="{{.URL}}">{{icon "folder"}} {{.Name}}</a> {{.Title}} · {{.Count}}</li>
  {{end}}
  {{range .Files}}
    <li class="kind-{{.Kind}}">
      <a href="{{.URL}}">{{icon .Kind}} {{.Name}}</a>
      {{.Title}} <span>{{.HumanSize}}</span>
      <time datetime="{{iso .UpdatedAt}}">{{date .UpdatedAt}}</time>
    </li>
  {{end}}
</ul>
{{end}}

Built-in icon names are logo, parent, folder and one per file Kind. The title block in the default theme shows the policy title, or the path, followed by the site title.

Template data: Page

Directory pages receive a Page. The same data, with snake_case field names, is served as JSON at DIR/?format=json. Field names are an extension contract — they are not renamed or removed within a major version.

FieldTypeMeaning
SiteSiteTitle (from VELA_SITE_TITLE) and URL (public origin)
TitlestringPolicy title; falls back to the directory name or site title
DescriptionstringPolicy description (plain text)
CustomTitleboolTrue if Title is an explicit policy title
NoIndexboolLayout must emit the robots meta tag when true
RootDisabledboolThe root index is disabled: do not link to /
PolicyCountsboolCounts are visible-entry counts (rules exist) rather than subtree file counts
PathstringCurrent root-relative directory path, with trailing /
Breadcrumbs[]CrumbRoot through current directory
Dirs[]DirVisible child directories with enabled, non-empty indexes
Files[]FilePublic, unexpired files in this directory
ParentstringRoot-relative parent URL; empty at the root or when the parent index is disabled
GeneratedAttime.TimeRender time (UTC)
VersionstringServer version
Session*SessionThe signed-in web session; nil for anonymous visitors
SignInURLstringSign-in link when web sign-in is enabled and the visitor is anonymous; empty otherwise

Nested types

Crumb

Name, URL (strings). An empty URL must render as text, not a link.

Dir

Name, URL, Title, Description (strings); Count (int — visible files plus listed child directories when rules exist, otherwise all public files below); UpdatedAt (latest reachable visible object); Flags ([]string: hidden, no-index).

File

Name, URL, Title, Description, HumanSize, ContentType, Kind (strings); Tags ([]string); Size (int64 bytes); UpdatedAt (UTC time); Flags ([]string: symlink, private, unlisted).

Session

Prefix (the key's directory prefix, empty with full access), Full (bool, the key has no prefix), SignOutURL (the action of the sign-out form).

Kind is one of image, video, audio, pdf, archive, code, text, document, spreadsheet, presentation, font or file — handy for icons and colors. URLs are root-relative and escaped per segment. Anonymous pages never receive private or unlisted objects; signed-in pages receive only those the session's key can see, and Flags mark them. Templates never receive keys, session IDs, signatures or blob IDs. A symlink is an ordinary File; only signed-in pages flag it with symlink.

{
  "title": "Documentation",
  "description": "Public handbooks",
  "noindex": false,
  "site": { "title": "Vela", "url": "https://store.example.com" },
  "path": "/docs/",
  "breadcrumbs": [ { "name": "Vela", "url": "/" }, { "name": "docs", "url": "/docs/" } ],
  "dirs": [],
  "files": [
    {
      "name": "welcome.txt", "url": "/docs/welcome.txt", "title": "", "description": "",
      "tags": [], "size": 15, "human_size": "15 B",
      "content_type": "text/plain; charset=utf-8",
      "updated_at": "2026-10-13T14:06:45.291Z", "kind": "text"
    }
  ],
  "parent": "/",
  "generated_at": "2026-10-13T14:07:01Z",
  "version": "v0.9.0"
}

Template data: ErrorPage

error.html receives an ErrorPage with Site, Status (int: 404, 410, …), Title, Message, GeneratedAt, Version, Session and SignInURL. NoIndex and RootDisabled are also available to the shared layout and are false on error pages.

Template data: LoginPage

login.html renders the web sign-in page. It receives a LoginPage: Site, Title ("Sign in"), Action (the form target), Error (the message of a failed attempt), NoIndex (true), RootDisabled, GeneratedAt, Version, Session and SignInURL — every field Page and ErrorPage share, so an existing layout renders it unchanged. The form must post a single key field to Action:

{{define "title"}}{{.Title}} · {{.Site.Title}}{{end}}

{{define "content"}}
<section class="login">
  <form method="post" action="{{.Action}}">
    <input type="password" name="key" autocomplete="off" required autofocus
           aria-label="API key" placeholder="API key">
    <button type="submit">Sign in</button>
  </form>
  {{with .Error}}<p class="message" role="alert">{{.}}</p>{{end}}
</section>
{{end}}

The shared layout must work with Page, ErrorPage and LoginPage; keep page-specific fields in the content templates.

Helpers

HelperResult
{{asset "style.css"}}/_vela/assets/style.css?v=<12-char content hash>. Unknown assets fail at startup.
{{icon "pdf"}}A trusted built-in inline SVG for a file kind or navigation icon
{{flagIcon "private"}}A visibility indicator: a focusable icon with aria-label and a data-tip tooltip. Unknown flags render nothing.
{{date .UpdatedAt}}UTC YYYY-MM-DD HH:MM; empty for a zero time
{{iso .UpdatedAt}}UTC RFC 3339 string, for <time datetime>

Assets and the Content Security Policy

Assets are served from /_vela/assets/. Versioned URLs produced by asset may be cached for a year; unversioned requests get a shorter lifetime. /favicon.ico serves the theme's assets/favicon.ico.

Index and error pages carry a strict policy that customization does not relax:

Content-Security-Policy: default-src 'self'; style-src 'self'; img-src 'self' data:;
                         base-uri 'none'; form-action 'none'; frame-ancestors 'none'
  • Use external stylesheets from assets/; inline <style> and style="" attributes are blocked.
  • Inline scripts are blocked; same-origin script files under assets/ are allowed.
  • Images from the same origin and data: URIs work; remote images, fonts and CDNs do not — ship them as assets.
  • Forms and framing are blocked. The sign-in page and pages rendered for a signed-in session use the same policy with only form-action 'self', which the sign-in and sign-out forms need.
  • Because inline styles and scripts stay blocked, indicator tooltips are drawn by CSS from data-tip on :hover and :focus; title is not used.

Directory policy compatibility

Since v0.2, custom themes must handle three cases introduced by directory policies. The default theme renders byte-for-byte as before while no rules are stored, so you can update at your own pace — but before creating the first rule:

  1. Empty breadcrumb URLs. Disabled ancestors have URL == ""; render the name as plain text:
    {{range .Breadcrumbs}}{{if .URL}}<a href="{{.URL}}">{{.Name}}</a>{{else}}<span>{{.Name}}</span>{{end}}{{end}}
  2. Empty parent. Suppress the “up” row when .Parent is empty. It stays a string — there is no Parent.URL.
  3. Robots meta tag. When .NoIndex is true, layout.html must include <meta name="robots" content="noindex, nofollow">.

Also honor RootDisabled for the brand link, and use .Title/.Description (plain text) for headings while keeping raw directory names for navigation.

Web sign-in support

v0.3 adds an optional web sign-in. Nothing here is required: themes without these calls keep working — they just show no indicators and no sign-in link — and without VELA_WEB_AUTH anonymous markup is byte-for-byte unchanged. To opt in:

  1. Indicators. Render {{range .Flags}}{{flagIcon .}}{{end}} after each directory and file name. Put them outside the name's link, because a link must not contain focusable elements:
    {{range .Files}}
      <li class="entry file kind-{{.Kind}}">
        <span class="link">
          <a href="{{.URL}}">{{icon .Kind}}<span class="name">{{.Name}}</span></a>
          {{range .Flags}}{{flagIcon .}}{{end}}
        </span>
      </li>
    {{end}}
  2. Footer. Offer SignInURL as a plain link, or show the session with a sign-out button — a POST form to Session.SignOutURL:
    <footer>
      Served by Vela {{.Version}}
      {{if .Session}}
        signed in: {{if .Session.Full}}full access{{else}}/{{.Session.Prefix}}{{end}}
        <form method="post" action="{{.Session.SignOutURL}}"><button type="submit">sign out</button></form>
      {{else if .SignInURL}}
        <a href="{{.SignInURL}}">sign in</a>
      {{end}}
    </footer>
  3. Tooltips. Style .flag::after { content: attr(data-tip); } and show it on .flag:hover and .flag:focus. Avoid overflow: hidden on the listing, which would clip it. The default style.css has a complete example.
  4. Sign-in page. Override login.html only if you want a different form; the embedded one renders inside your layout.

Unknown flags render nothing, so future releases can add flags without breaking your theme.