How to publish a blog on Amazon S3 with the static Blog engine'Pelican'for Pythonista

Amazon S3 is a well-known service that can host static files on the Web. Pelican is a minor tool in Japan, but it is a Python tool that generates html nicely if you create a file in Markdown or reStructuredText format. The name "Pelican" seems to come from "calepin", which refers to notes in French.

Pelican http://docs.getpelican.com/en/

It's quite minor in Japan, where Python isn't popular, but it feels very simple and easy to use, so I want everyone to use it! There aren't many themes yet, so I want someone to make one! (Other power application)

This time, I give an example of hosting on Amazon S3, but it is also easy for Heroku and Github Pages. It can be uploaded to, and I feel that it has the minimum functionality such as tags, highlights of programming code, and RSS.

Advance preparation


Will be carried out first. The domain of Amazon S3 seems to be long and delicate, so I think that you need your own domain. I proceeded with the setting by referring to the following blogs.

Assign your own domain to your AWS S3 bucket to host static files-a niche WordPress diary

important point

  1. When operating with a root domain instead of a subdomain, domain registration with Amazon Route 53 is required.

  2. When operating as a web page, the bucket name of S3 and the domain of the blog must match.

Install Pelican


I use Python 2.7 series. It's easy to use pip.

$ pip install pelican

If you want to write in Markdown format, also here.

$ pip install markdown

After installation, execute the quick start command.

$ pelican-quickstart

Many questions will be asked, so please answer them in order.

After completing the input, a template for the Pelican project will be created.

$ ls
content/
output/
Makefile
develop_server.sh
pelicanconf.py
publishconf.py

content/

A folder to put Markdown or reST format files. It is a working folder for users to edit blogs.

output/

The final html output destination.

Makefile

It outputs html, checks the contents on localhost, and provides various commands.

pelicanconf.py

Pelican configuration file. If you want to change the settings of your blog, you usually edit this one.

publishconf.py

Commercial settings. Edit the information you need when you actually publish. Settings for comment input by Google Analytics and Disqus.

Try to write an article


For the time being, let's create a file in Markdown format under content without touching the above configuration file. After "This is ..." is the text in Markdown format, and above that is the syntax for telling Pelican the title, date, tags, etc. of the blog. "Slug" is the URL of the article represented by a hyphenated string in the title. If you look at the URL of each article in Huffingtonpost, you will get an image.

Title: My super title
Date: 2010-12-03 10:20
Tags: thats, awesome
Category: yeah
Slug: my-super-post
Author: Alexis Metaireau
Summary: Short version for index and feeds

This is the content of my super blog post.

Create a file page.md like the one above in content /. If possible

$ make html

With html output,

$ make serve

Since the local server works with, let's check with localhost: 8000. You should see that the md file created above can be viewed as html. It's easy!

Deploy to S3


If you can do it so far, it is finally deployed to S3. Install a tool called s3cmd and configure it with configure.

$ pip install s3cmd
$ s3cmd --configure

You will be asked another question, but you can leave it blank except for the access key and secret key.

Next, for those who set the commercial individual setting to publishconf.py

$ make publish

Issue a command. It just changes the config file to read to publishconf.py and makes html.

Finally

$ make s3_upload

The file is now uploaded to S3 and you can browse the blog.

I'm studying too, so I'd like to add some information here and there. Basically, you study while looking at Documents. The fate of Python is that the information is mostly in the English-speaking world ...

__Addition __ I have summarized the settings that are likely to change frequently in another article. Various settings of Python static blog generation tool'Pelican'

Recommended Posts

How to publish a blog on Amazon S3 with the static Blog engine'Pelican'for Pythonista
How to get the key on Amazon S3 with Boto 3, implementation example, notes
How to create a submenu with the [Blender] plugin
How to build a Python environment on amazon linux 2
How to set a shared folder with the host OS in CentOS7 on VirtualBOX
The guy who stumbled upon failing to publish a blog on github pages on Pelican
How to publish GitHub Pages with Pelican, a static HTML generator made by Python
A memo on how to overcome the difficult problem of capturing FX with AI
A story about how to deal with the CORS problem
POST the image selected on the website with multipart / form-data and save it to Amazon S3! !!
A note on how to check the connection to the license server port
[Introduction to Python] How to split a character string with the split function
How easy is it to synthesize a drug on the market?
How to make a command to read the configuration file with pyramid
How to customize U-Boot with OSD335X on a custom board (memo)
How to send a request to the DMM (FANZA) API with python
How to run the practice code of the book "Creating a profitable AI with Python" on Google Colaboratory
Think about how to write a filter with the Shotgun API-Contact Versions
How to add a package with PyCharm
[Python] Explains how to use the range function with a concrete example
[Introduction to Python] How to sort the contents of a list efficiently with list sort
How to update php on Amazon linux 2
How to draw a vertical line on a heatmap drawn with Python seaborn
How to install Anisble on Amazon Linux 2
How to fix the initial population with a genetic algorithm using DEAP
[Introduction to Python] How to write a character string with the format function
How to test on a Django-authenticated page
Upload data to s3 of aws with a command and update it, and delete the used data (on the way)
How to deal with "^ [[A ^ [[B ^ [[C ^ [[D"] when you press the arrow keys when executing python on mac
[2015/11/19] How to register a service locally using the python SDK on naoqi os
How to access the contents of a Linux disk on a Mac (but read-only)
[Python] How to save images on the Web at once with Beautiful Soup
Checklist on how to avoid turning the elements of numpy's array with for
[AWS] Wordpress How to deal with "The response is not a correct JSON response"
How to get a list of files in the same directory with python
I tried to create a model with the sample of Amazon SageMaker Autopilot
[Introduction to Python] How to get the index of data with a for statement
How to calculate the volatility of a brand
How to send a message to LINE with curl
Crop the image to rounded corners with pythonista
How to specify the NIC to scan with amazon-dash
How to draw a 2-axis graph with pyplot
Strategy on how to monetize with Python Java
How to develop a cart app with Django
How to make a dictionary with a hierarchical structure.
How to try the friends-of-friends algorithm with pyfof
How to install OpenGM on OSX with macports
Introduction to Python with Atom (on the way)
Save the object to a file with pickle
How to live a decent life on 2017 Windows
How to create a multi-platform app with kivy
How to Learn Kaldi with the JUST Corpus
How to identify the element with the smallest number of characters in a Python list?
[Don't refer to 04.02.17] Display the temperature sensor on a real-time graph with rasberry pi 3.
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
How to test the current time with Go (I made a very thin library)
Read the Python-Markdown source: How to create a parser
How to convert / restore a string with [] in python
Think about how to program Python on the iPad
How to write a GUI using the maya command
How to put Takoyaki Oishikunaru on the segment tree