Forexperiments

Various experiments with forex and other stuff
it en

New platform!

2023-02-14 4 min read Magnetic_dud

I’ve been behind a redesign of the site for months and finally posted it today!

This then is the version … 3.0? I think so.

What was wrong with the old site? Nothing much… just that WordPress was irritating me!

WordPress is convenient as a blogging platform: once installed just log in to add new posts, you don’t have to be an IT guy to write new content. Unfortunately, I must say that in recent times I have noticed a disturbing increase in traffic to my site from Russian IP addresses, which account for about 75% of the total traffic. How many of these were real people trying to read what I wrote? If there was only one I would be surprised! And yet they are hammering my server with thousands of login attempts, pornographic comments, etc….

So with each new email from WordFence (a firewall for WordPress, a must-have) notifying me of a blocked bruteforce, blocked SQL injection, it made me want to switch to Hugo more and more.

For those who do not know, Hugo is an open source static website generator. Unlike WordPress, which uses a database to store and retrieve data, Hugo generates static Web pages directly from source code. This means that there is no need to worry about data security and a database, which makes Hugo invulnerable to hacker attacks: there is no login or exploit to prevent, it’s all static pages, like it was back in the year 1996!

In addition to the increased security, being a static page is much much faster in loading, because there is nothing to compute, no database to query, etc…

In theory there is a wide range of themes and templates to create a beautiful and professional website… but maybe these themes are also too many! Choosing one is a real job! They all look good at first glance, you really have to try them out to see if they are right for you or not, if you can customize them as you wish. I was stuck four months at this stage.

Once I have chosen a theme that seems to suit me, I then tried to migrate the old posts that I still had on Blogger: first you export to XML, then convert to markdown using one of too many available methods. I chose the Python one - which, however, has NO DOCUMENTATION AT ALL, And it was also removed from the author’s Bitbucket, so you can’t even go and ask for info… good thing that the beauty of open source is that you can see the code manually and because it’s a simple program with not too many lines it’s possible to figure something out…

The command to use it is

python ./blogger_to_hugo.py forexperimenti.xml forexperimenti/

Finished? No. It was not specified, but it is necessary to install Pandoc - in my case I took pandoc.exe contained in the file pandoc-xxx-windows-x86_64.zip. And it automatically generated markdown files for me for each individual post.

Now the real business begins: to really understand how it all works, and get some confidence.

My site is multilingual, each post is in English and Italian, manually translated, not automatically, so it is slightly more complex, the configuration file has to be modified following the official documentation

Then, to see the themes, to try them out, it’s fine to just download the files, however, when it’s time to get serious, it’s best to use it as a git submodule with:

git submodule add https://github.com/Lednerb/bilberry-hugo-theme themes/bilberry

I then noticed that the import program did an imperfect job: it did not import all the content, stopping in the middle of 2012, with the files not well processed… every single post has to be manually reviewed, and in these ten years I have posted hundreds and hundreds of posts…

Finally, the tool mis-downloaded all the post images…

I spent a whole day trying to figure out how to do insert images in my posts, I even tried an optional program like FrontMatter but I didn’t quite understand how to use it - until I asked ChatGPT. The AI explained it to me in two very concise lines:

  1. images are placed in /static, and if you want you can organize them by years, or as you wish. For example /static/images/2022/test.jpg
  2. when you want to insert an image, write: ![Alternative text to the image, as a description for those who cannot view it](/images/2022/test.jpg)

Then you spend another hour or so looking at the theme instructions on how to set up the config.toml file properly and voila, the blog is served!

What an effort! The result is very snappy though, I like it very much.

Now I just need to waste a few more weeks trying to find a way to let people comment on my posts…