How to publish GitHub Pages with Pelican, a static HTML generator made by Python

How to publish GitHub Pages with Pelican, a static HTML generator made by Python

Overview

To publish GitHub Pages, I created a page using Pelican, a static HTML generator made by Python. I was addicted to the release, so make a note of the procedure as a memorandum. The detailed procedure is very helpful because the following reference site is detailed, so it is good to work based on that.

1. Environment

2. Outline of procedure

  1. Install pelican
  2. Install ghp-import
  3. Create a GitHub Pages project
  4. Create a local repository
  5. Run pelican-quickestart
  6. Enter pelican-quickestart
  7. Creating an article
  8. Confirmation of article
  9. Publish to GitHub Pages
  10. Push the master branch

3. Detailed procedure

3-1. Installation of pelican

# pip install pelican

3-2. Installation of ghp-import

# pip install ghp-import

3-3. Creating a GitHub Pages project

Create a repository from the GitHub Pages page. There are two types, one for users and one for projects, but this time I created it for users.

3-4. Creating a local repository

Clone the repository.

# git clone <Repository URL>

3-5. Run pelican-quickestart

# pelican-quickstart

3-6. Input of pelican-quickstart

> Where do you want to create your new web site? [.]
> What will be the title of this web site? yusukew62 blog
> Who will be the author of this web site? yusukew62
> What will be the default language of this web site? [en] ja
> Do you want to specify a URL prefix? e.g., http://example.com   (Y/n) Y
> What is your URL prefix? (see above example; no trailing slash) http://yusukew62.github.io
> Do you want to enable article pagination? (Y/n) Y
> How many articles per page do you want? [10]
> What is your time zone? [Europe/Paris] Asia/Tokyo
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) Y
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) Y
> Do you want to upload your website using FTP? (y/N) N
> Do you want to upload your website using SSH? (y/N) N
> Do you want to upload your website using Dropbox? (y/N) N
> Do you want to upload your website using S3? (y/N) N
> Do you want to upload your website using Rackspace Cloud Files? (y/N) N
> Do you want to upload your website using GitHub Pages? (y/N) y
> Is this your personal page (username.github.io)? (y/N) y
Done. Your new project is available at /root/testpelican

3-7. Creating an article

When pelican-quickstart is completed, the following files will be created.

Makefile  content  develop_server.sh  fabfile.py  output  pelicanconf.py  publishconf.py

Create an article to post under the content directory. This time I created an article with reStructuredText, which is more like Python. When creating with Markdown, put Markdown from pip.

# vi content/20161210.rst

Article example


First Post By Pelican
#####################

:date: 2016-12-08 12:00
:modified: 2016-12-10 14:40
:tags: Python, Pelican
:category: Python
:authors: yusukew62
:summary: first post by pelican

.. code-block:: python

    print "Hello World"

3-8. Confirmation of article

Generate an html file.

# make html

Check the display.

# make serve

Connect to the IP address of the above execution host with a browser on port 8000.

3-9. Published on GitHub Pages

Output the file published on GitHub Pages to the gh-pages branch.

# ghp-import output

Add the generated html file to your local repository.

# git add output/
# git commit -m 'Added all created html files'

Publish a set of files from the gh-pages branch to the master branch of the remote repository

# git push -f origin gh-pages:master

After a while, make sure the page is refreshed.

3-10. Push master branch

The gh-pages branch does not include the content directory or pelican configuration file (* .py), so cut another branch and push it. Here, it is created as a branch called source from master and uploaded to the remote repository.

# git branch source
# git push origin source

Access from a browser and check

http://<User name>.github.io

4. Reference

I referred to the following site. How to create a blog managed by Pelican + Markdown + GitHub Pages

Recommended Posts

How to publish GitHub Pages with Pelican, a static HTML generator made by Python
How to deal with old Python versions in Cloud9 made by others
How to read a CSV file with Python 2/3
How to publish a blog on Amazon S3 with the static Blog engine'Pelican'for Pythonista
How to convert / restore a string with [] in python
Dynamic HTML pages made with AWS Lambda and Python
[Python] How to draw a line graph with Matplotlib
How to save a table scraped by python to csv
[Python] How to create a 2D histogram with Matplotlib
[Python] How to draw a scatter plot with Matplotlib
The guy who stumbled upon failing to publish a blog on github pages on Pelican
How to deploy a web app made with Flask to Heroku
How to install NPI + send a message to line with python
[Python] How to make a list of character strings character by character
How to convert an array to a dictionary with Python [Application]
How to build a python2.7 series development environment with Vagrant
How to override a user-defined method generated by python swig
I made a class to get the analysis result by MeCab in ndarray with python
How to batch start a python program created with Jupyter notebook
How to write a Python class
Python: How to use async with
A story about adding a REST API to a daemon made with Python
[Introduction to Python] How to split a character string with the split function
How to make a surveillance camera (Security Camera) with Opencv and Python
I made a fortune with Python.
[Python] A memo to operate ROM created by GBDK with PyBoy
How to create a heatmap with an arbitrary domain in Python
How to get started with Python
[Python] How to get a value with a key other than value with Enum
How to use FTP with Python
How to calculate date with python
Pass a list by reference from Python to C ++ with pybind11
[ROS2] How to play a bag file with python format launch
I made a daemon with Python
How to send a request to the DMM (FANZA) API with python
Easy procedure to start blogging with Python's static site generator "Pelican"
How to debug a Python program by remotely connecting to a Docker container in WSL2 environment with VS Code
Python: I tried to make a flat / flat_map just right with a generator
I made a password generator to teach Python3 to children (bonus) * Completely remade
I tried to communicate with a remote server by Socket communication with Python.
I made a tool to automatically browse multiple sites with Selenium (Python)
I made a web application in Python that converts Markdown to HTML
[Python] Explains how to use the range function with a concrete example
Create a tool to automatically furigana with html using Mecab from Python3
[Introduction to Python] How to sort the contents of a list efficiently with list sort
How to draw a vertical line on a heatmap drawn with Python seaborn
I tried to discriminate a 6-digit number with a number discrimination application made with python
[Introduction to Python] How to write a character string with the format function
How to sort by specifying a column in the Python Numpy array.
3. Natural language processing with Python 1-2. How to create a corpus: Aozora Bunko
How to create a clone from Github
How to add a package with PyCharm
[Python] How to make a class iterable
[Python] How to convert a 2D list to a 1D list
I made a character counter with Python
How to work with BigQuery in Python
[Python] How to invert a character string
How to get a stacktrace in python
How to do portmanteau test with python
How to display python Japanese with lolipop
Try HTML scraping with a Python library