1
Fork 0
This repository has been archived on 2020-05-05. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Henrique Dias cd52fd25dd fix: trimming
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2020-02-16 19:45:27 +00:00
layouts fix: trimming 2020-02-16 19:45:27 +00:00
README.md docs: add readme 2020-02-16 19:42:35 +00:00
config.yaml feat: add caddy redirects 2020-02-16 19:37:36 +00:00
go.mod feat: add caddy redirects 2020-02-16 19:37:36 +00:00

README.md

Caddy redirects for Hugo

Generate a redirects file compatible with the http.redir plugin from Caddy.

Usage

Add the module import to your Hugo config file:

module:
  imports:
    # other imports
    - path: github.com/hacdias/hugo-caddy-redirs

Then enable the output file for home:

# 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