A Blog About D4T4 & M47H

Moving My Blog from Jekyll/GitHub to Pelican/GCS

28 May ’18

I recently moved this blog from Jekyll/GitHub to Pelican/GCS. Mainly, I wanted to move to a Python-based framework where I would have more flexibility to customize (e.g. add/create plugins). And cost isn't really a consideration as both options are free. GitHub pages is actually powered by Jekyll and gives you free hosting on GitHub's domain. The fully-rendered blog is <<1Gb, and you get 5Gb of GCS storage for free.

I used Google Container Builder for CI/CD to publish my website on a GCS bucket, drawing upon a lot of ideas from this tutorial. The build has the following steps:

  1. Pull from GitHub - This performs a shallow git clone of my repo on GitHub.
  2. Generate site with Pelican - I needed to create a custom Google Container Builder step for this. See Dockerfile below. In addition to installing Pelican and some other Python depenencies, this container also installs Sass for CSS.
  3. Push to GCS Bucket - This uploads the HTML generated by Pelican to a GCS bucket using gsutil rsync.

I needed to update a few settings on the GCS bucket to serve the site, namely setting a link to the index page (MainPageSuffix) and making the site globally readable. Finally, I set up build triggers; whenever I push to my master branch, it automatically triggers a build.

Overall, I'm loving Pelican so far. You can find my blog's new repo here. Cheers!


  - name:
    args: ['clone', '-b', '${_BRANCH}', '--single-branch', '--depth', '1', '']
  - name:${PROJECT_ID}/pelican:latest
    args: ["content", "-v"]
    dir: blog-pelican
  - name:
    entrypoint: gsutil
    args: ["-m", "rsync", "-r", "-c", "-d", "./output", "gs://${_SUB_DOMAIN}"]
    dir: blog-pelican
  _BRANCH: master
  _SUB_DOMAIN: www

Dockerfile for Pelican GCB step


ENV PATH /builder/dart-sass:${PATH}

COPY requirements.txt .

# requirements.txt:
# blinker==1.4        Markdown==2.6.11        pytz==2018.4
# docutils==0.14      MarkupSafe==1.0         six==1.11.0
# feedgenerator==1.9  pelican==3.7.1          Unidecode==1.0.22
# Jinja2==2.10        Pygments==2.2.0         webassets==0.12.1
# jsmin==2.2.2        python-dateutil==2.7.3

RUN pip install --no-cache-dir --upgrade setuptools \
  && pip install --no-cache-dir --upgrade -r requirements.txt

RUN apt-get update \
  && apt-get install -y wget \
  && rm -rf /var/lib/apt/lists/*

RUN wget -q -O /builder/dart-sass.tar.gz${SASS_VERSION}/dart-sass-${SASS_VERSION}-linux-x64.tar.gz \
  && tar xvzf /builder/dart-sass.tar.gz --directory=/builder \
  && rm /builder/dart-sass.tar.gz

ENTRYPOINT ["pelican"]