[PYTHON] Try to introduce the theme to Pelican

Introducing the theme and how to introduce the theme with'Pelican', a static blog generation tool made by Python.

Click here for the above.

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

-Various settings of Python static blog generation tool'Pelican'

After the introduction of Pelican, I think you'll want to look more elaborate. Pelican comes with a theme function that you can replace with your favorite theme.

Setting method


It's very easy to do, in the config file (pelicanconf.py)

THEME ='(theme)'

I just write it like this. Some themes are created by volunteers,

https://github.com/getpelican/pelican-themes

All are placed in. For now, let's copy the above directory locally.

git clone --recursive https://github.com/getpelican/pelican-themes ~/pelican-themes

For the last ~ / pelican-themes part, specify the directory where you want to place the theme. This will download all themes (many!), So the rest is the PATH of the theme directory you want to use.

THEME = "/home/user/pelican-themes/theme-name"

Just specify it in the configuration file like this.

http://pelican-themes-gallery.place.org/

You can also check the preview with, so try applying a nice one,

make html → make serve

It is a good idea to check the appearance on the local server with.

This blog also uses a customized theme of svbhack (which may change). You can edit the dropped theme yourself, so you have a lot of freedom. I'll customize it and make my own theme! In that case

Knowledge is essential.

An example of customization --- Linkage with DISQUS's comment function


Since pelican does not have a comment function, you need to install an external service such as DISQUS if you want to add it.

Depending on the theme, it may or may not be attached by default, and the svbhack theme also did not have a comment function, so I added it.

(1) Register your site with DISQUS

From TOP, it should be easy to follow the introduction. If you can't, google (・ 3 ・)

You should get a name called shortname that uniquely identifies your site on the DISQUS side, so make a note of it.

Note) With the current DISQUS specifications, the language used "Japanese" cannot be selected. I also corrected it by referring to the article below.

What to do if Japanese cannot be set with the comment plug-in "DISQUS"

It seems that the settings themselves exist on the server side, so I hope DISQUS will respond quickly without doing such tricky things.

(2) Reflect DISQUS settings in pelican

If you have created a pelican blog project with the quickstart command,

publishconf.py

There should be the following description in.

publishconf.py


# Following items are often useful when publishing

DISQUS_SITENAME = ""

If you specify the short name you wrote down earlier, DISQUS settings will be reflected on the pelican side for the time being.

(3) Editing html

There are some themes that can be used up to (2), but if they are not supported, you need to write a DISQUS call by yourself.

For example, in the case of the svbhack theme,

/svbhack/templates

There is a file called article.html in it, which is the template used to display the article, so you can write the following just before the article closing tag.

article.html


	:
	:
	{% if DISQUS_SITENAME %}
    <div class="comments">
      <div id="disqus_thread"></div>
          <script type="text/javascript">
              var disqus_identifier = "{{ article.url }}";
              (function() {
                  var dsq = document.createElement('script');
                  dsq.type = 'text/javascript';
                  dsq.async = true;
                  dsq.src = 'http://{{ DISQUS_SITENAME }}.disqus.com/embed.js';
                  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
          })();
          </script>
      </div>
    {% endif %}

    </div>
    </article>

The items from {% if DISQUS_SITENAME%} to {% endif%} are subject to addition.

If DISQUS_SITENAME is set, it means to embed the embed code of the comment.

If you do this, DISQUS comments should be displayed at the end of the article like this blog!

Knowledge of jinja2 is required to play with Pelican templates, but it is quite major in Python's template engine, and it is a loss to suppress. I don't think there is.

Postscript

Described the draft function.

-Try using Pelican's draft function

Recommended Posts

Try to introduce the theme to Pelican
Added Theme to Pelican Blog
Cython to try in the shortest
The fastest way to try EfficientNet
The easiest way to try PyQtGraph
Try to face the integration by parts
Python amateurs try to summarize the list ①
Try adding fisheye lens distortion to the image
Try to decompose the daimyo procession into Tucker
Try to solve the Python class inheritance problem
Try to solve the man-machine chart with Python
How to try the friends-of-friends algorithm with pyfof
Try to simulate the movement of the solar system
Try posting to Qiita for the first time
Try to solve the programming challenge book with python3
[Python] Try to read the cool answer to the FizzBuzz problem
Try setting SSH (Exscript) from the software to the router
Try setting NETCONF (ncclient) from software to the router
Try to solve the problems / problems of "Matrix Programmer" (Chapter 1)
Try to solve the internship assignment problem with Python
Introduce serverspec to Linux
Molecular dynamics simulation to try for the time being
Try to estimate the number of likes on Twitter
Try to get the contents of Word with Golang
Try to implement yolact
[Neo4J] ④ Try to handle the graph structure with Cypher
The road to Pythonista
Try to decipher the login data stored in Firefox
The road to Djangoist
Introduce elpy to emacs
Try to specify the axis with PyTorch's Softmax function
I tried to introduce the block diagram generation tool blockdiag
Try to get the function list of Python> os package
Try to evaluate the performance of machine learning / regression model
Try to play with the uprobe that supports Systemtap directly
Try connecting to Supervisord via XMLRPC to start / stop the program
Try to evaluate the performance of machine learning / classification model
Try to improve the accuracy of Twitter like number estimation
Try to solve the problems / problems of "Matrix Programmer" (Chapter 0 Functions)
Try to automate the operation of network devices with Python
Try to extract the keywords that are popular in COTOHA
Try to model a multimodal distribution using the EM algorithm
[Introduction to Reinforcement Learning] Reinforcement learning to try moving for the time being
Try to decipher the garbled attachment file name with Python
Try to extract the features of the sensor data with CNN
How to use the generator
Dot according to the image
The road to download Matplotlib
Try using the Twitter API
Try the Taxii server (1. Server settings)
Try using the Twitter API
Try using the PeeringDB 2.0 API
I tried to introduce Pylint
Change the theme of Jupyter
How to install Pelican blog
Try to select a language
Try doubling the PyODE slider
How to use the decorator
How to increase the axis
How to start the program
[Note] Let's try to predict the amount of electricity used! (Part 1)