How to deploy your static Pelican website to Netlify
Tags: python, pelican, webdev, netlify
Published: 2020-02-23 16:07:49

This article was first published on [razcodes.dev](https://razcodes.dev/ "razcodes.dev")

In the [previous article](https://dev.to/razcodes/how-to-create-a-static-website-using-pelican-24he "Static website using Pelican") I talked about creating the static website. Now it's time to deploy it. I started by creating a free account on [Netlify](https://www.netlify.com/ "Netlify").

## Domains

One of the first things to consider would be the domain name. You can go with one that is provided by Netlify, or you can register your own. I already had my own domain [razcodes.dev](https://razcodes.dev/ "razcodes.dev") that I registered with [Google Domains](https://domains.google.com/ "Google Domains").

I logged into my account and went to **Domains** in the top menu and added my domain by following the instructions on the screen. I then went back to Google Domains and put in the NS servers provided, under DNS settings.

Back on my machine, I edited the 'publishconf.py' file so the URL matches my domain:

```bash
SITEURL = 'https://razcodes.dev'
```

## Source Control

In order to get the website up and running I needed to upload it to either GitHub, Gitlab or Bitbucket. That is where Netlify is going to reach out and pick it up from. I went with [GitHub](https://github.com/ "GitHub").

Since the website will be rebuilt every time we upload to source control and also because it's good practice, I created the 'requirements.txt' file. With the virtual environment activated:

```bash
pip freeze > requirements.txt
```

In GitHub, I created a new repository, gave it a name, set it to private and clicked the button. What I like here is that even if you are not comfortable with git, on the next page after creation, they give you the instructions on how to get your code in.

I added a '.gitignore' file in my main website folder so I can tell git what not to upload. There is this cool website that helps you create that file if you are not sure what to include called [gitignore.io](https://www.gitignore.io/ "GitIgnore").

Back in the console, in the website folder, I got everything ready:

```bash
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/razcodesdotdev/my-pelican-website.git
git push -u origin master
```

## Creating the site

Back on the Netlify website, under **Sites** I clicked on _New Site from Git_. I clicked on GitHub and authorized the connection between the websites as well as pointed to the new repo that I created.

For the Branch to deploy I chose **master**. Under the build command, I put in the following:

```bash
pelican content -s publishconf.py -t theme
```

For the Publish directory I put in **output** because that is the folder name where the website gets built.

I clicked **Deploy site**.

As the website was deploying, I went under **Domain settings** for the new site and added in my custom domain, as well as provisioned a free SSL certificate from [Let's Encrypt](https://letsencrypt.org/ "Let's Encrypt"). All done automatically by Netlify just by clicking a few buttons. For free.