From 161f01afc49f156c34bf044c85d41d1adcca9d17 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 16 Feb 2020 19:42:35 +0000 Subject: [PATCH] docs: add readme License: MIT Signed-off-by: Henrique Dias --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a81f6cf --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Caddy redirects for Hugo + +Generate a redirects file compatible with the [`http.redir`](https://caddyserver.com/v1/docs/redir) plugin from Caddy. + +## Usage + +Add the module import to your Hugo config file: + +```yaml +module: + imports: + # other imports + - path: github.com/hacdias/hugo-caddy-redirs +``` + +Then enable the output file for home: + +```yaml +# Optional: disable the generation of HTML aliases. +disableAliases: true + +# Mandatory +outputs: + home: + - html # Default + - rss # Default + - redir +``` + +This will create a `redirects.txt` file on the root of your website. Now you can +add a rule to your Caddy configuration to use this file as the 301 redirects: + +``` +redir 301 { + import /the/public/path/redirects.txt +} +``` + +## Thanks + +Thanks to @jlelse for the improvement on adding the version with and without the trailing slash. + +## License + +MIT