My Pelican Structure and Workflow

I've been using Pelican as my static site generator now exclusively for a while. I've migrated everything off of dynamic CMS like WordPress, because, frankly, I don't need the functionality, and I love the ease and inexpensiveness of hosting things on S3.

I figured I'd outline my Pelican structure and workflow. It might be helpful to others. I finally got it to a place that really works for me.

First, I'm storing these on S3, and also using AWS for SSL certificates. You might want to read those first.

I generally write my blog posts in Visual Studio Code, but I've also used Markdown editors as well, which can be nicer.

I use the same Pelican template for all but one of my sites (this one, actually), which makes things a little easier. I'm probably going to change that at some point. At some point, I'm also going to write a blog post about how I converted an open source online HTML/CSS template to a pelican template. It was a pain, but not that much of a pain (frankly, it was only a pain becuase the front end is my kryptonite.)

Pelican has in it a Makefile, and one of the options is s3_upload, which is what I use.

For S3, just add the bucket you want in the variables at the top: (It should be in the form of a domain name - see the above links.)

Then, in the place with 's3_upload: publish'

aws s3 sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --profile profile_name --grants read=uri= where 'profile_name is the name of your profile in the credentials file under .aws directory.

One of the things about hosting your domain using S3 and cloudfront is that it's cached by AWS. You can either simply wait, but I like to create an "invalidation" which basically clears the cache right before I publish.

Handily, I've been working on some simple AWS functions and scripts see more here, although I need to write an update to this! So I have a handy script here

I set up an alias in .bash_aliases:

alias makemp='source ~/venv/simple_aws_prod/bin/activate; python ~/ --profile=profile_name; deactivate; source ~/venv/pelican/bin/activate; cd /mnt/c/Users/me/Dropbox/Code/Sites/; make s3_upload; deactivate'

That alias clears the website cache, uploads the new files, and ... poof! Site is updated instantly. I'm loving this workflow.