Setting Up My Blog (First Post)

Posted by Dustin January 29, 2019

First Post!

For my first post I am attempting to document how I setup this blog. I already realize how I failed and could improve on the process of creating and implementing tutorial-style posts. For one, I need a hell of a lot more pictures/screenshots taken when I am working through something. My notes could also be 1000x better. Anyway, obvious observations aside… here we go!

Installing/Using Hakyll

So, I actually ran into a bunch of issues trying to install Hakyll. For the sake of transparency, I’m trying to relay all of them. Some of them were just space issues I am having due to a small, old, SSD where I installed my OS. Others, were just me not realizing the obvious. :)

I had dependency issues all over the board. After talking with some coworkers, I realized I forgot to change the stack resolver. Well, I naively changed it to the latest LTS (13.2 at time of this writing), assuming that Hakyll was included. I was wrong. I had to change the resolver to 12.26–which comes with GHC 8.4.4. That got things rolling. I also had to do some shenanigans with my locale setting, but it is all relayed below.

Here is essentially the troubleshooting process I encountered for getting this blog up:

Deps Issues

With these, I went so far as to trying to individually add suggested dependencies:

I also tried the set allow-newer: true method in C:\sr\config.yaml. No dice.

After doing some Googlin’, I found this post in an issue and tried it. It worked so I took out the recommended deps to keep my stack.yaml as clean as possible.

The only extra-deps I have now are

Building

When running stack exec site build, I got:

commitBuffer: invalid argument (invalid character)

So, based on this FAQ, I set my locale encoding in my site.hs to

That seemed to fix it up real nice.

Since I wanted to use brittany for formatting my Haskell code–which is what we use at work–I went with lts-12.26.

I installed brittany based on the README from their github and “she” is formatting quite well. :)

I went with CleanMagic for Hakyll for the theme for the time being so I could just get this bad boy up and running and have at least some sense of style. This blog will be a constant WIP(work in progress). So, expect changes and updates to styling, etc. all of the time.

Hosting On AWS

I made a free tier account on AWS. I plan on using AWS for most of personal development work since it coincides with my professional work as well. Also, a lot of the stuff on AWS is pretty cool if you can get past some of their jargon.

Sidenote: A coworker sent me this and it is wonderful: AWS In Plain English

I bought the domain you are currently at on GoDaddy and followed this pretty straightforward tutorial by Benjamin Rodarte. It’s basically an A-Z tutorial of setting up a static site with HTTPS enabled using AWS S3, AWS Cloudfront, and GoDaddy.

Rather than regurgitate what’s there, I figure pointing someone in that direction would be a wiser use of everyone’s time. I would like to add that due to the nature of my work, most of the concepts and components in that tutorial are more than familiar to me. So, it was extremely easy and useful for me to follow. This isn’t a crappy attempt at “humble bragging”–it is a fact. Therefore, your mileage may vary. Hopefully, it proves as useful to you as it did to me.

A Bucket Is Worth A Thousand Cups… Maybe

After getting all of the infrastructure set up, I now needed to generate my site and stick it in the S3 bucket I set up for hosting. To do this, I ran the following command in the terminal:

stack build
stack exec CleanMagic-hakyll rebuild

I chose the rebuild Hakyll command instead of the build Hakyll command because I wanted the entire thing, including recompiling site.hs, to be built again. This eased my overly cautious mind that nothing would be left out. The build/rebuild commands will generate things that have changed, but does not include the site.hs. To recompile site.hs, we need that stack build you see above.

There is a link to all of the commands you can utilize on the Hakyll site, but let’s face it: I’m lazy. You’re lazy. Denying it is about as cool as wearing a tube sock as a beard hat (don’t ask just google it). Here is the link to the commands for a quick ref: Hakyll commands

There is a nice deploy command that I will be looking into customizing in a future post. For the time being, I am manually dropping my _site folder into S3, then setting the bucket to serve up the index from that folder. Also, I forgot to change the siteCtx baseurl constant in my site.hs from http://localhost:8000 to https://www.dustinsegers.com. Oops! I then had to redo the build commands over again to recompile site.hs and generate the site utilizing my new baseurl.

After all that, the blog is up! Yeah!

The End Of The Beginning

That sums up most of what I encountered in creating this blog. Aside from constant tweaking of CSS, HTML, and markdown, there isn’t much else I can expound upon. I’m shooting for my next post or so to begin my endeavors with Terraform and implementing my infrastructure as code.

~ Til next time!