- HTML 100%
Caddy Browse Grid Template #
A modern, feature-rich directory listing template for the Caddy web server. It provides a beautiful grid and list view, a built-in media gallery, and various enhancements over the default Caddy file browser.
Features #
- Dual Layouts: Toggle between a visual Grid view and a detailed List (table) view.
- Media Gallery: Built-in lightbox for viewing images and videos without leaving the page.
- Audio Dock: Persistent bottom dock for playing audio files while browsing.
- Direct File Links: Shareable
?file=URLs that open a specific file straight in the viewer or audio dock. - Thumbnails & Covers:
- Automatically loads
.thumb.jpgsidecar files for image thumbnails. - Automatically loads
cover.jpgfor folder preview covers.
- Automatically loads
- JXL Support: Native detection for JPEG XL (
.jxl) images, with automatic WebAssembly polyfill fallback (jxl.js) for unsupported browsers. - Dark/Light Mode: Respects system preferences and includes a manual toggle.
- Search & Filter: Real-time filtering of directory contents.
- Keyboard Navigation: Arrow keys, page up/down, and shortcuts (e.g.,
/for search,g/lfor grid/list view). - Responsive Design: Mobile-friendly layout and touch targets.
Installation & Usage #
- Download or clone this repository to your server.
- Update your
Caddyfileto use this custom template for thefile_serverdirective:
example.com {
root * /path/to/your/files
file_server browse {
template /path/to/caddy-browse-grid/browse.html
}
}
- Reload or restart Caddy.
Sharing Direct Links to Files #
Append ?file=<filename> to any directory-listing URL to link straight to a specific file:
https://example.com/photos/?file=Screenshot_2026-09-04_21-38-11.png
When the listing loads, the file opens automatically:
- Images (including JPEG XL via the built-in polyfill on unsupported browsers), videos, Markdown, PDFs, code/text, and HTML files open in the built-in preview viewer.
- Audio files start playing in the audio dock.
Things to know:
- The parameter takes a bare filename only — no paths. It always refers to a file inside the directory being listed.
- It works even when the file is on another page of a paginated listing.
- While the viewer is open, the URL updates to reflect the open file, so copying the address bar at any time gives you a shareable direct link.
Recommended: disable_canonical_uris #
Directory URLs carry your view preferences in the query string, e.g.:
https://example.com/photos/?sort=name&order=desc&layout=grid&file=Screenshot_2026-09-04_21-38-11.png
Caddy's canonical trailing-slash redirect can wipe those parameters out (depending on your setup, e.g. behind a reverse proxy), so add disable_canonical_uris to your file_server block to make sure they are respected:
example.com {
root * /path/to/your/files
file_server browse {
template /path/to/caddy-browse-grid/browse.html
disable_canonical_uris
}
}
Note that this does not remove the trailing slash — a slash-less directory URL still redirects to the /photos/ form — and it also disables the other canonicalization redirects (e.g. rewriting index.html URLs), not just the trailing-slash one.
Customization & Sidecar Files #
To make the most of the visual features, you can generate sidecar files alongside your media:
- Image Thumbnails: For an image named
photo.png, place a thumbnail namedphoto.png.thumb.jpgin the same directory. The template will use this for the grid view, falling back to the original image if not found. - Folder Covers: Place a
cover.jpginside any directory to use it as the visual representation for that folder in the parent directory's grid view.
License #
Please refer to the LICENSE file in this repository or the original author's terms.