I am not a person, who can do nothing for very long. So, when I found myself in between university and my first developer job, I decided on starting a Blog. This is it. Welcome :-)
Before starting the blog, I had some requirements for it:
- I wanted to host it myself.
- I wanted to create it using
- Publishing should be as easy as possible.
- I wanted to write articles on my own machine and publish them by simply
- uploading them to the server.
- I wanted to write articles in the Markdown format.
The Python community being the Python community, I immediately found an interesting blogging framework called Pelican. It offered static file generation from Markdown files, plenty of plugins and themes, and with ~8.5k start on GitHub it seemed to be pretty battle tested. Here is how I set up Pelican on my CentOS 7 server.
Pelican own installation instructions are pretty explicit already, but let me walk you through them step-by-step.
Before getting started, make sure to create a new
Pelican. Then, execute the following commands one-by-one.
# Install Pelican, Markdown, and all other dependencies pip install pelican markdown # Create a directory for your blog mkdir blog # Move to the new directory cd blog # Create the Pelican Project pelican-quickstart # Answer all the questions. You can later on always # change your answers in the generated pelicanconf.py file
You can use Pelicans documentation to explore all ways of writing content, but for an initial setup, create a sample post like this:
# Create a folder that will hold all of your posts mkdir content # Create a first sample post touch content/sample-post.md
sample-post.md file with the following data:
Title: My First Post Date: 2019-02-04 Category: Test This is my first post. Here are some tests: This is a test of **bold text** This is a test of *cursive text* This is a test of a [link](https:/www.google.com) This is a test of some code: `python main.py`
After you created a first post, run
pelican content to generate the static
html pages from your posts in
content. To view your blog, run
pelican --listen and navigate your browser to http://localhost:8000.
If you want auto generation of pages whenever you add or modify a post in
content, open another tab and run
pelican -r content. Pelican will now
listen for any changes to the
content folder and automatically re-run
pelican content whenever something changes.
Alternatively to running
pelican -r content, you can also either install
pip install invoke and run
invoke regenerate or simply use
make command and run
make regenerate. Both commands will work
pelican -r content.