|
| 1 | +--- |
| 2 | +title: "Hugo Theme" |
| 3 | +weight: 55 |
| 4 | +--- |
| 5 | + |
| 6 | +The `hugo-theme-hedgerules` Hugo theme provides output format layouts, data partials, and table partials for working with Hedgerules headers and redirects. |
| 7 | + |
| 8 | +## Output format layouts |
| 9 | + |
| 10 | +These templates generate the files that `hedgerules deploy` reads. |
| 11 | + |
| 12 | +### `index.hedgeheaders.json` |
| 13 | + |
| 14 | +Generates `_hedge_headers.json`, a JSON file mapping paths to HTTP header objects. Enable it via `[outputs]` in `hugo.toml`: |
| 15 | + |
| 16 | +```toml |
| 17 | +[outputs] |
| 18 | + home = ["HTML", "hedgeheaders", "hedgeredirects"] |
| 19 | +``` |
| 20 | + |
| 21 | +### `index.hedgeredirects.txt` |
| 22 | + |
| 23 | +Generates `_hedge_redirects.txt`, a text file with one `source destination` pair per line. Enable it alongside `hedgeheaders` as shown above. |
| 24 | + |
| 25 | +## Data partials |
| 26 | + |
| 27 | +These partials return data and can be called from your own templates or shortcodes. |
| 28 | + |
| 29 | +### `hedgerules/redirects.html` |
| 30 | + |
| 31 | +Returns a map of all redirects (source path to destination path). Sources are collected in this order: |
| 32 | + |
| 33 | +1. Site-wide `HedgerulesRedirects` from `hugo.toml` |
| 34 | +2. Hugo `aliases` from page frontmatter |
| 35 | +3. `HedgerulesPathRedirects` from page frontmatter |
| 36 | + |
| 37 | +The result is cached on `hugo.Store` so it is only computed once per build. |
| 38 | + |
| 39 | +```go-html-template |
| 40 | +{{ $redirects := partial "hedgerules/redirects.html" . }} |
| 41 | +{{ range $source, $dest := $redirects }} |
| 42 | + {{ $source }} -> {{ $dest }} |
| 43 | +{{ end }} |
| 44 | +``` |
| 45 | + |
| 46 | +### `hedgerules/headers.html` |
| 47 | + |
| 48 | +Returns a map of all headers (path to header dict). Sources are merged in this order (later wins): |
| 49 | + |
| 50 | +1. `HedgerulesPathHeaders` from `hugo.toml` |
| 51 | +2. `HedgerulesHeaders` from page frontmatter |
| 52 | + |
| 53 | +The result is cached on `hugo.Store` so it is only computed once per build. |
| 54 | + |
| 55 | +```go-html-template |
| 56 | +{{ $headers := partial "hedgerules/headers.html" . }} |
| 57 | +{{ range $path, $headerDict := $headers }} |
| 58 | + {{ $path }}: |
| 59 | + {{ range $name, $value := $headerDict }} |
| 60 | + {{ $name }}: {{ $value }} |
| 61 | + {{ end }} |
| 62 | +{{ end }} |
| 63 | +``` |
| 64 | + |
| 65 | +## Table partials and shortcodes |
| 66 | + |
| 67 | +These partials render HTML tables and are useful for documentation or debugging pages. |
| 68 | + |
| 69 | +### `hedgerules/redirectsTable.html` |
| 70 | + |
| 71 | +Renders an HTML table with Source and Destination columns for all redirects. |
| 72 | + |
| 73 | +```go-html-template |
| 74 | +{{ partial "hedgerules/redirectsTable.html" . }} |
| 75 | +``` |
| 76 | + |
| 77 | +This is also available as a shortcode. |
| 78 | + |
| 79 | +```markdown |
| 80 | +{{</* hedgerules/redirectsTable */>}} |
| 81 | +``` |
| 82 | + |
| 83 | +On this site, it renders like this: |
| 84 | + |
| 85 | +{{< hedgerules/redirectsTable >}} |
| 86 | + |
| 87 | +### `hedgerules/headersTable.html` |
| 88 | + |
| 89 | +Renders an HTML table with Path, Header, and Value columns for all headers. |
| 90 | + |
| 91 | +```go-html-template |
| 92 | +{{ partial "hedgerules/headersTable.html" . }} |
| 93 | +``` |
| 94 | + |
| 95 | +This is also available as a shortcode. |
| 96 | + |
| 97 | +```markdown |
| 98 | +{{</* hedgerules/headersTable */>}} |
| 99 | +``` |
| 100 | + |
| 101 | +On this site, it renders like this: |
| 102 | + |
| 103 | +{{< hedgerules/headersTable >}} |
0 commit comments