Path Prefix#
Serve multiple repositories under different paths of the same domain.
Use Case#
You want to serve archived content or versioned documentation under paths like:
https://www.example.com/2019/https://www.example.com/2020/https://www.example.com/v1/docs/
Configuration#
apiVersion: pages.kup6s.com/v1beta1
kind: StaticSite
metadata:
name: archive-2019
namespace: pages
spec:
repo: https://github.com/org/archive-2019.git
domain: www.example.com
pathPrefix: /2019
---
apiVersion: pages.kup6s.com/v1beta1
kind: StaticSite
metadata:
name: archive-2020
namespace: pages
spec:
repo: https://github.com/org/archive-2020.git
domain: www.example.com
pathPrefix: /2020How It Works#
- Both sites share the same TLS certificate (one per domain)
- Traefik routes based on path prefix before the host match
- Requests to
https://www.example.com/2019/page.htmlserve fromarchive-2019repo - Requests to
https://www.example.com/2020/page.htmlserve fromarchive-2020repo
Several StaticSites can serve different directories of one repository, each with its own path and pathPrefix.
Each site keeps its own clone, but only checks out and downloads its own directory, so disk use stays close to the size of the repository.
This needs a git server with partial-clone support (GitHub, GitLab, Gitea and Forgejo have it).
Other servers send the full repository to each site.
Requirements#
pathPrefixrequires a customdomainto be set- Path prefixes must be unique per domain
- The prefix is stripped before serving (so
/2019/index.htmlservesindex.htmlfrom the repo) - A directory without trailing slash redirects to the public URL with slash (
/2019→/2019/)
Root Path#
To serve a “main” site at the root while having prefixed sub-sites, create a site without pathPrefix:
apiVersion: pages.kup6s.com/v1beta1
kind: StaticSite
metadata:
name: main-site
namespace: pages
spec:
repo: https://github.com/org/main-website.git
domain: www.example.com
# No pathPrefix → serves at rootTraefik will route /2019/* and /2020/* to their respective sites, and everything else to the main site.