TL;DR - I want my AMP paths to be mysite.com/:slug/amp/
.
I have the following in my config.
[outputFormats]
[outputFormats.HTML]
[outputFormats.AMP]
path = "?? - this is what i'm stuck on"
[outputs]
home = ["HTML", "AMP"]
page = ["HTML", "AMP"]
post = ["HTML", "AMP"]
[permalinks]
post = "/:slug/"
When I have a new post at say content/post/dog-toys.md
its path will be mysite.com/dog-toys/
as expected.
I can’t seem to figure out how to make that same path with a /amp/ at the end work w/ hugo, except for aliases (more on that below).
I have tried:
path = ":slug/amp/"
(and a few variations of leading/trailing slashes) - this doesn’t seem to ever insert the slug though.
path = "amp"
- this does what I expected and makes the path mysite.com/amp/dog-toys/
for amp pages, and is the default value
So I said I can get aliases to work. What I mean is, if i have the following in a post:
slug = "dog-toys"
aliases = ["toys"]
Then I run hugo
the file public/toys/amp/index.html
is created by the hugo
command and redirects to mysite.com/amp/dog-toys/
.
I’m using hugo v0.34 if that helps, and I’m also not too picky on the end results. That is, I don’t mind mysite.com/:slug/amp/
redirecting to mysite.com/amp/:slug/
, I just want to avoid broken links. I’m migrating from Ghost and all of their AMP routes were /:slug/amp/
by default.
Any suggestions on what to try next?