Publishing this blog to an S3 bucket

This is a short post adding to the testing notes from the previous post where I created an S3 bucket to host my static site. To test that it worked I had to upload something and ended up doing most of what I had intended for this blog post. If you're reading my adding SSL series but are only interested in the CloudFormation bits you can skip this post as it doesn't contain any.

For the tests in my previous post I relied on all .html pages being generated in the same base directory as their sources. But as I don't intend to check in the generated files, I don't want to continue that! Instead I want the generated files to end up in ~/public_html on my machine, so I can preview them. I intend to do much like what I do now: cd into the root directory containing the generated blog and issue the command python -m SimpleHTTPServer.

So, I have to change my publishing setup. For the processing of the Org files I just have to change the :publishing-directory setting from ~/blog to ~/public_html but I have to add a new project to deal with static files. This project looks like so:

(setq org-publish-project-alist
         :base-directory "~/blog"
         :publishing-directory "~/public_html"
         :base-extension "css\\|jpg\\|png\\|pdf"
         :recursive t
         :publishing-function org-publish-attachment)

Now, after I have reviewed the changes to the generated files (by browsing to I have to upload the generated files to S3. This is similar to how I uploaded the test files in the previous post, but now that the directory only contains generated files I can shorten it to make the --exclude line more specific and contain fewer --include lines. My script looks like this:


set -gx AWS_PROFILE stig
aws s3 sync \
    --acl public-read \
    --exclude '.DS_Store' \
    ~/public_html/ s3://

Posted 23 July 2017 Copyright © Stig Brautaset