I just spent the past 6 hours trying and failing to issue a Let’s Encrypt TTL certificate for a Hugo site that is hosted on Gitlab Pages.
Even though the token and the key were successfully accessible though the browser the ACME challenge failed spectacularly each time.
I finally discovered that the token page requires just the value without any html and the {{ .Content }} variable was always wrapping the Let’s Encrypt token in <p> tags.
My way to get around this issue was by making two new sections. ACME and ACME-www (for the naked domain and the www version respectively) In each one I made a blank single.html with nothing but the tokens.
Then in the Content/ACME and Content/ACME-www I created markdown files specifying the URL in the Front Matter.
And BANG! it worked like a charm. So I am sharing this workaround to save the pain from anyone who comes across similar trouble while trying to issue a Let’s Encrypt TTL Certificate for a Hugo site.
Every tutorial that I found was about Jekyll that has a variable called layout: null to the best of my knowledge there is nothing like it in Hugo or is there?
However in the static folder the Let’s Encrypt token needs to be saved as a .html file and specifying the token’s URL with front matter does not work.
One will have to replicate the required path structure with folders. So it really depends on what one thinks will be best for maintenance. A couple of empty sections and corresponding .md files or a bunch of nested folders in /static/ .
2nd EDIT
If one uses my approach instead of the suggestion made by @bep it will be necessary to exclude the Let’s Encrypt pages from the sitemap.xml see this thread for more info:
@alexandros I think there are a number of ways to do what you want to do. My current favorite approach is to host my source on Github (you can use GitLab too), then give the access to the repo to netlify. Then I do this:
Press a button (for CI/CD)
Press another button for Let’s Encrypt
Crazy. Easy.
For the record, I have zero affiliations and receive zero dollars from Netlify, although it’s getting to point where my recommendations across these forums is probably getting a big gratuitous