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.
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.
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.
Described the draft function.
-Try using Pelican's draft function
Recommended Posts