From c43d7ca68686c02f4a1a2629c51a57e381b6427e Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 6 Sep 2025 23:42:16 +0000 Subject: [PATCH] docs(botstopper): add HTML templating support Signed-off-by: Xe Iaso --- docs/docs/admin/botstopper.mdx | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/docs/docs/admin/botstopper.mdx b/docs/docs/admin/botstopper.mdx index 56ad14c..4175ed4 100644 --- a/docs/docs/admin/botstopper.mdx +++ b/docs/docs/admin/botstopper.mdx @@ -197,6 +197,96 @@ $ du -hs * 8.0K reject.webp ``` +## Custom HTML templates + +If you need to completely control the HTML layout of all Anubis pages, you can customize the entire page with `USE_TEMPLATES=true`. This uses Go's standard library [html/template](https://pkg.go.dev/html/template) package to template HTML responses. In order to use this, you must define the following templates: + +| Template path | Usage | +| :----------------------------------------- | :---------------------------------------------- | +| `$OVERLAY_FOLDER/templates/challenge.tmpl` | Challenge pages | +| `$OVERLAY_FOLDER/templates/error.tmpl` | Error pages | +| `$OVERLAY_FOLDER/templates/impressum.tmpl` | [Impressum](./configuration/impressum.mdx) page | + +Here are minimal (but working) examples for each template: + +
+`challenge.tmpl` + +:::note + +You **MUST** include the `{{.Head}}` segment in a `` tag. It contains important information for challenges to execute. If you don't include this, no clients will be able to pass challenges. + +::: + +```html + + + + {{ .Head }} + + + {{ .Body }} + + +``` + +
+ +
+`error.tmpl` + +```html + + + + {{ .Body }} + + +``` + +
+ +
+`impressum.tmpl` + +```html + + + + {{ .Body }} + + +``` + +
+ +### Template functions + +In order to make life easier, the following template functions are defined: + +#### `Asset` + +Constructs the path for a static asset in the [overlay folder](#custom-images-and-css)'s `static` directory. + +```go +func Asset(string) string +``` + +Usage: + +```html + +``` + +Generates: + +```html + +``` + ## Customizing messages You can customize messages using the following environment variables: