<commit_before>Title: Set up website with Pelican, Google Domains and Netlify
Date: 2017-06-19


### Prelude

The GitHub repository for this website is located at <https://github.com/edwinksl/edwinksl.github.io>. Issues, pull requests, comments and suggestions are welcome!

### Introduction

This website is set up using [Pelican](https://blog.getpelican.com/) as the [static site generator](https://www.staticgen.com/), [Google Domains](https://domains.google/) for registering a custom domain and [Netlify](https://www.netlify.com/) for hosting the website. The choice of a static site generator is arbitrary and I picked Pelican because it is written in Python and is the most active among various Python static site generators that I am aware of. The main motivation for using Netlify instead of GitHub Pages is because GitHub Pages does not support SSL for custom domains. See this epic [GitHub issue](https://github.com/isaacs/github/issues/156) for complaints and workarounds regarding this problem.

This post seeks to summarize the steps for setting up a website using Pelican, Google Domains and Netlify, and is based on the following excellent documentation, guides and tutorials:

1. Pelican's [documentation](http://docs.getpelican.com/en/stable/)
2. Netlify's guides for [hosting a Pelican website on Netlify](https://www.netlify.com/blog/2015/10/15/a-step-by-step-guide-pelican-on-netlify/) and [setting up a custom domain](https://www.netlify.com/blog/2016/03/14/setting-up-your-custom-domain/)
3. Netlify's documentation for [continuous deployment](https://www.netlify.com/docs/continuous-deployment/) and [enabling HTTPS](https://www.netlify.com/docs/ssl/)

The instructions are given for Ubuntu, specifically Ubuntu 17.04, but they should generalize well to other Linux distributions and operating systems.

### Custom domain

1. Register for a custom domain. I registered mine at Google Domains, so the instructions for this post are based on that. The procedures for setting up a custom domain with Netlify are slightly different for different domain name registrars, which we will discuss later.

### Pelican

1. We will use a [virtual environment](https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments), which is commonly abbreviated as virtualenv, to manage the Python dependencies. Therefore, we first install `virtualenv`:

        sudo apt update
        sudo apt install virtualenv

2. Create and activate a virtualenv in the Git repository, or repo for short, for the website. My Git repo is located at `~/git/edwinksl.github.io/`, so the commands are:

        cd ~/git/edwinksl.github.io/
        virtualenv venv -p python3.6  # create a virtualenv for Python 3.6
        source venv/bin/activate

    If you prefer Python 3.5, change `python3.6` to `python3`. If you prefer Python 2.7, omit `-p python3.6` and run just `virtualenv venv`. Remember to add `venv/` to `.gitignore` as we are not interested in keeping it under version control. The `pip` that is shipped with Ubuntu can be [buggy](https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1579181), so I usually [force-upgrade `pip`](https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1579181/comments/3) right after activating a new virtualenv as follows:
    
        pip install -U --force-reinstall pip

3. Use `pip` to install `pelican` and other optional packages, namely `Markdown` and `typogrify`:

        pip install pelican Markdown typogrify

4. Follow either the [quickstart tutorial](http://docs.getpelican.com/en/stable/quickstart.html) or the [detailed documentation](http://docs.getpelican.com/en/stable/) to set up Pelican and write content. The basic workflow consists of running `make devserver` to serve the website locally at <http://localhost:8000/>, iterate content writing and finally running `make stopserver` to stop the development server.


5. In the root of the Git repo, add a file named `CNAME` that contains the custom domain. In my case, `CNAME` contains `www.edwinksl.com`.<commit_msg>Copy editing<commit_after>Title: Set up website with Pelican, Google Domains and Netlify
Date: 2017-06-19


### Prelude

The GitHub repository, or repo for short, for this website is located at <https://github.com/edwinksl/edwinksl.github.io>. Issues, pull requests, comments and suggestions are welcome!

### Introduction

This website is set up using [Pelican](https://blog.getpelican.com/) as the [static site generator](https://www.staticgen.com/), [Google Domains](https://domains.google/) for registering a custom domain and [Netlify](https://www.netlify.com/) for hosting the website. The choice of a static site generator is arbitrary and I picked Pelican because it is written in Python and is the most active among various Python static site generators that I am aware of. The main motivation for using Netlify instead of GitHub Pages is because GitHub Pages does not support SSL for custom domains. See this epic [GitHub issue](https://github.com/isaacs/github/issues/156) for complaints and workarounds regarding this problem.

This post seeks to summarize the steps for setting up a website using Pelican, Google Domains and Netlify, and is based on the following excellent documentation, guides and tutorials:

1. Pelican's [documentation](http://docs.getpelican.com/en/stable/)
2. Netlify's guides for [hosting a Pelican website on Netlify](https://www.netlify.com/blog/2015/10/15/a-step-by-step-guide-pelican-on-netlify/) and [setting up a custom domain](https://www.netlify.com/blog/2016/03/14/setting-up-your-custom-domain/)
3. Netlify's documentation for [continuous deployment](https://www.netlify.com/docs/continuous-deployment/) and [enabling HTTPS](https://www.netlify.com/docs/ssl/)

The instructions are given for Ubuntu, specifically Ubuntu 17.04, but they should generalize well to other Linux distributions and operating systems.

### Custom domain

1. Register for a custom domain. I registered mine at Google Domains, so the instructions for this post are based on that. The procedures for setting up a custom domain with Netlify are slightly different for different domain name registrars, which we will discuss later.

### Pelican

1. We will use a [virtual environment](https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments), which is commonly abbreviated as virtualenv, to manage the Python dependencies. Therefore, we first install `virtualenv`:

        sudo apt update
        sudo apt install virtualenv

2. Create and activate a virtualenv in the Git repo for the website. My Git repo is located at `~/git/edwinksl.github.io/`, so the commands are:

        cd ~/git/edwinksl.github.io/
        virtualenv venv -p python3.6  # create a virtualenv for Python 3.6
        source venv/bin/activate

    If you prefer Python 3.5, change `python3.6` to `python3`. If you prefer Python 2.7, omit `-p python3.6` and run just `virtualenv venv`. Remember to add `venv/` to `.gitignore` as we are not interested in keeping it under version control. The `pip` that is shipped with Ubuntu can be [buggy](https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1579181), so I usually [force-upgrade `pip`](https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1579181/comments/3) right after activating a new virtualenv as follows:
    
        pip install -U --force-reinstall pip

3. Use `pip` to install `pelican` and other optional packages, namely `Markdown` and `typogrify`:

        pip install pelican Markdown typogrify

4. Follow either the [quickstart tutorial](http://docs.getpelican.com/en/stable/quickstart.html) or the [detailed documentation](http://docs.getpelican.com/en/stable/) to set up Pelican and write content. The basic workflow consists of running `make devserver` to serve the website locally at <http://localhost:8000/>, iterate content writing and finally running `make stopserver` to stop the development server.


5. In the root of the Git repo, add a file named `CNAME` that contains the custom domain. In my case, `CNAME` contains `www.edwinksl.com`.
{'fraction_non_alphanumeric': 0.09199654704649156, 'fraction_numerical': 0.017758046614872364, 'mean_word_length': 4.300653594771242, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 26, 'lorem ipsum': 0, 'www.': 14, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '752054', 'n_tokens_mistral': 2392, 'n_tokens_neox': 2183, 'n_words': 956}