Yes, i looked into the uglyURL setting right away… but as you’ve been able to guess, it’s not “ugly” enough for the way that AWS CF and S3 play together.
I will open a support ticket w/ amazon asking for the ‘index.html’ behavior to be the same regardless or which S3 endpoint is used to access the content.
Hi bep. I am working with AWS support on this currently. You’re right that an ‘implied index.html’ works fine with CloudFront when the distribution is configured to sit in front of an S3 static website endpoint. In that mode, S3 is acting as a webserver which can do this. But switch to using a OAI directly, as documented at https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html, and a hugo-generated site breaks hard.
I would very much prefer not to use compute to simply rewrite requests to specify index.html.
Any other users out there know how to get around this? Perhaps there’s a config I’m doing wrong on AWS? If yes I would hope/assume the AWS CloudFront guy I’m working with would know about it; I’m suspecting not.
Regardless, it would be just fantastic if Hugo had a rendering option whereby the full URL including index.html were always emitted, and we never had to rely on this website feature of serving an implied url.
Is this possible in Hugo, while still rendering relative URLs?
Rather than use {{ .RelPermalink }} or {{ .Permalink }}, you could use {{ .File.Path }}. However, I would want to find another way rather than using a workaround just because of your hosting provider. I suppose you could use {{ .Render "url" }} or something like that to alternate between the two if you decide to change it later.
IMO, the ideal option would be a config setting which would enabling rendering behavior which would explicitly link to */index.html rather than just to the containing directory.
I believe the Lambda Edge option for URL rewriting will be able to be a workaround for now. But it sure does feel like a kludge. …I’d be very happy if there’s some config feature in CloudFront which doesn’t require explicit URLs in all cases, but so far, we haven’t found it.
Confirming for others here that according to AWS Support, AWS CloudFront using an Origin Access Identity is not compatible with websites where index.html is implicit