This article is also posted on My Blog, so please take a look if you like.
A major remodeling of my own something like a static site generator that I used on my blog for a long time. , I made a primitive static site generator "blogen.py". Click here for the repository: blogen.py
There are various static site generators in the world. Gatsby Yara Hexo Yara. There are several reasons why we did something like reinventing the wheel without using those sophisticated ones.
--I didn't understand how to use the existing static site generator ――I wanted to design the site myself ――I didn't like the fact that extra files were likely to be generated.
When I first started making this, I wasn't very motivated to learn, so I didn't like using new tools. ~~ It's still the case ~~ In the end, I was able to make something like that with my poor knowledge of Python. However, at that time, I didn't know the existence of HTML template engines such as Jinja2, and I didn't understand how to synthesize pieces of HTML files prepared in advance. After all, I rewrote it to use Jinja2, but I had a hard time because of such a rugged design. Knowledge is important.
At the time of writing this article, blogen.py has the following features:
--Article / top page generation function --Blog directory generation function --Notification Tweet function on Twitter
On the contrary, the functions that are not currently provided (I want to implement) are as follows.
--Writing an article by Markdown --Article categorization --Ability to divide the articles on the top page into n pages --Like button --Comment section
This is really the only feature I have implemented. There is also a feature that a link to share the article on Twitter is generated under the article (please check it out), but it is not a feature of blogen.py because it was just implemented in JavaScript. To put it the other way around, even with such a small number of functions, at least it can be established as a blog. This was a realization I couldn't get if I was using an existing tool.
After creating and using blogen.py, I found some advantages of creating my own static site generator.
Well, this is natural because it is a self-made and ultra-low-performance tool.
Since I wrote the CSS completely myself, the design is almost completely free. I'm happy because this was one of my initial goals.
Of course, it is a major premise that you have technical capabilities.
I think that it will increase the knowledge and implementation power because it will be messed up at the time of implementation. At the very least, it is possible to write quickly when you think "I want a little tool".
Of course, it wasn't all good points.
You can't use it right away because you have to implement all the features yourself. It's a hassle. Well, that's fun too.
For example, if you do not allow you to adjust the number of articles displayed on the top page, it will theoretically be too large to load at some point. Besides, if you implement categorization, you will have to modify all articles. Even now that there are only a dozen articles, if there are hundreds of articles, the correction work will be very difficult.
When I googled with "Static site generator self-made", surprisingly everyone made their own static site generator. You are the only one who hasn't made it yourself. However, it is amazing that everyone has made it properly. Since blogen.py is made up of "I wish I could use it! W" -like glue ... But it's fun, I made my own static site generator. Would you like to try it once?
Recommended Posts