Using Andrew for Your Site

Let's look at three items:
  1. developing a site with Andrew
  2. building and distributing a site with andrew
  3. taking the tedium out of boilerplate pieces of your page

Developing The Site

Andrew performs lookups live from the file system, so if you add a new article it'll just show up without restarting the server. Run Andrew in a directory and just write your html/javascript/css files into your site structure.

I maintain this site as a github repo. The root of the site is in the website directory. So I do this:

cd /path/to/website/
go run github.com/playtechnique/andrew/cmd/andrew@v0.0.5 #defaults to running on localhost:8080 in the pwd
Then I open my browser at localhost:8080 and get to work.

Building and Distributing the Site with Andrew

Andrew's got github releases for the 3 major OSes, so you can use the binaries from there if you want. I don't; I build straight from source into a really lightweight container:

FROM golang:1.22 AS base

WORKDIR /usr/src/app

ENV CGO_ENABLED=0
RUN go install github.com/playtechnique/andrew/cmd/andrew@v0.0.5 #or whatever version you want to use; this is current as of today

FROM scratch

COPY --from=base /etc/passwd /etc/passwd
USER 1000 #User 1000 comes for free from the golang container
COPY --from=base /go/bin/andrew /andrew
COPY --chown=1000:1000 website /website

EXPOSE 8080
ENTRYPOINT ["/andrew", "/website", "0.0.0.0:8080", "https://playtechnique.io"]

Removing the Tedium of Boilerplate in HTML docs

Naturally there's a whole lot of boilerplate for every article. I use templ to minimise this.

You can see in my templ templates github repository where I keep my article template. I use it like this:

templ article | templ DATE=$(date +%Y-%m-%d) TITLE=article-title > webpage/article.html

If you want to use templ yourself, there's a homebrew tap available, or you can go install it:

brew tap playtechnique/homebrew-templ
brew install templ

OR

go install github.com/playtechnique/templ@0.2.0 #the current version; tags can be seen at https://github.com/PlayTechnique/templ/tags