mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
23 hours ago a6cd7954455ae921e88a49280809811a1d0c4a35
docs: show use of custom outputs
1 files modified
40 ■■■■■ changed files
README.md 40 ●●●●● patch | view | raw | blame | history
README.md
@@ -57,8 +57,46 @@
* [Customisation](https://ananke-documentation.netlify.app/customisation/)
* [Troubleshooting](https://ananke-documentation.netlify.app/troubleshooting/)
## Custom outputs
Ananke does not require theme changes for Hugo custom outputs. Define the output format in your site configuration and add the matching layout file to your site. Hugo resolves project layouts before theme layouts, so the custom output can live outside the theme.
For example, this configuration adds a `SearchIndex` JSON output for the home page:
```toml
[mediaTypes."application/json"]
suffixes = ["json"]
[outputFormats.SearchIndex]
mediaType = "application/json"
baseName = "index"
isPlainText = true
notAlternative = true
[outputs]
home = ["HTML", "RSS", "SearchIndex"]
```
Then add a matching layout in your site at `layouts/index.searchindex.json`:
```go-html-template
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections -}}
[
{{- range $index, $page := $pages }}
  {{- if $index }},{{ end }}
  {
    "title": {{ $page.Title | jsonify }},
    "permalink": {{ $page.RelPermalink | jsonify }},
    "summary": {{ $page.Summary | plainify | jsonify }}
  }
{{- end }}
]
```
This produces `/index.json` while keeping Ananke's default HTML and RSS output intact.
## Support and Contributions
* Bug reports: [GitHub Issues](https://github.com/gohugo-ananke/ananke/issues)
* Questions and feature ideas: [GitHub Discussions](https://github.com/gohugo-ananke/ananke/discussions)
* Contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md)
* Contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md)