I have setup AWS CLI and S3 policy/permissions. I am using the ICARUS theme on a MacBook Air. With “hugo serve” the website looks perfect. Then I do “hugo” to generate the public files. All of them are generated in the public folder. I then copy those files in the public folder to another folder, to do a sync to S3 using AWS CLI. Here is what I get (first few lines, and then the last line, since the output is very long):
$ aws s3 sync . s3://aws-website-mybucket --acl public-read --exclude ‘*.DS_Store’
upload failed: 2016/06/01/the-unexamined-suitcase-is-not-worth-carrying—part-1–luggage/index.html to s
upload failed: img/p16-006-6.jpg to s3:// etc.
Have you set up iam with public/private keys in the command line so that you have access to write to that bucket? Have you set up everything in your bucket in the AWS console?
@monkeysandwine what was the issue? Add a comment about it in case others find this thread later and experience the same hiccup. Whatever it was, I’m glad you got it worked out. Btw, I’m now pushing my site to GH pages. S3 is great, but GH pages consistently had better server response time in my tests. Cheers.
Of course. There were 3 issues in deploying my website with Hugo theme Icarus on AWS S3 with Cloudfront.
Upload failed to S3: I had to reconfig my AWS CLI properly with the right zone (from us-west-2 to us-east-1) and insert the correct rights policy for my S3 bucket. The following command line worked:
aws s3 sync . s3://mybucket --acl public-read --exclude ‘*.DS_Store’
Error on Folders and Subfolders. S3 can have default pages for a directory when you do not specify a specific file (such as index.html). While I had S3 configured correctly to server a default document when going to directories, that same behavior isn’t translated over to CloudFront. The webbrowser return an error when the links do not end with an “.html” file. To solve this I had to:
(a) insert in the config.toml file the code uglyurls = true
(b) change the [permalinks] to post = “/:year/:month/:title.html”
Tags and Categories links. The same issue I had with folders and subfolders could not be resolved with the config.toml changes for the Categories and Tags links generated by the widgets. So this is the only issue left to resolve, which just raised an issue with digitalcraftsman on github. For example, I now have this for links:
But I would like to have this for my links to work with AWS Cloudfront:
I think I need to configure the “layout/partials/widget/” files in the theme, but I am not sure how. I can’t find any documentation on this, but I have to admit, I started using Hugo maybe 2 weeks ago, so I am a total newbie. Any ideas?
For all those involved, great work making Hugo. I had tried Jekyll and Hexo just before Hugo, and still have nightmares about configuring the nodes on my Mac. Hugo is way easier to work out-of-the-box and incredibly fast. Well done!