Python Static Site Generator

I completed the main parts of generating a Computer Log Static Site. Almost all the Blog posts are created many of the images display. The Index shows all 456 of my posts. There are some image linking problems. The image link problem’s are from using WordPress’s upload feature. The images linked to my image directory work fine. I have a problem with forward slashes (which designates a directory in Linux, in the file name, for example RSTS/E so I changed those to back slashes in the file name. This worked on my Linux file system. But FTP failed to upload them on my Linux server. So I may have to rethink the filename. It took ~38 seconds to create the Static Site. All the Python code ran fast. But calling the external program to convert markdown to HTML put the brakes on the speed.

WP blog to Static Site

Started work on my own WordPress to markdown, to Static Site using Python. Got as far as creating modified markdown that includes date and title. Output filename changed to “date/time title”. Bypass external comments. Plan on using Python nodule (md-to-html) that converts markdown to html.

My own Log SSG?

Talked about it here. This whole topic started because of a WordPress search failure. I don’t think I want to devote the time right now but possibly in the future. Like I said my judoplaces static website was created in 2013, using Python/SQLite long before SSGs became a thing, before that the it was created with MS-Access. Thinking more about it, especially after recently reviewing the steps to create from WordPress. I think I could consolidate the last 5 steps into 1 step with more control including breaking up one long index page to multiple pages. Then again I could just do all those steps initially, since they already work, and then going forward, update the site using markdown, perhaps store the markdown in SQLite. Having the log in SQLite would allow me to easily retrieve the entries in date order or search on any field, rather than making Python do it. Just brainstorming right now!

Static Blog Search

The WordPress to Static Site by the Eleventy SSG went pretty well. Even considering my admitted lack of interest in web design. I made some very basic changes and improved the look considerably. The only or at least biggest thing missing is search. But there are many possibilities right off the top of my head. Perhaps the simplest is simply running a grep on the markdown files which will show the Title. Or perhaps a simple Python program that can go through the files and present a html select screen.

Static blog (11ty) to my server

After solving (so far) the FTP problem, I finally moved a test small sample of my static log file, created by 11ty to my server and it didn’t work! The problem was not using relative addressing. Or am I missing something? It seems…for a static site generator, that I should be able to simply move the files to my server and it would work. I do seem to remember reading someone’s tutorial about having to fix link addresses. Surely I’m missing something…maybe a switch? Unless 11ty is only designed to work with netlify? All the other tutorials I read seemed to use that method.

Anyhoo I wrote a python program to fix the hrefs in the main index.html. In hind site I could have simply used a text editor to change ‘href=”/posts/…’ to ‘href=”posts/…’ but at the time I thought I would have the program do more. After which…it worked. Isn’t pretty (that can be worked on), but it worked! Web design isn’t my thing but I did add some borders/white space. And here it is, maybe a few small fixes needed. No PHP…no SQL. Just static site goodness. I think I said it before but I’ll say it again, I find the fact that 11ty reads the date/time in the front matter, and sorts the index correctly (newest entries at top) very cool. Some entries such as Star Trek also include images! Today I’m approaching 500 WordPress posts and wouldn’t want to recopy everything, every time I made a change or new entry, so I can use Filezilla’s copy options to not rewrite existing entries.

So to recap, steps to create Static Site from WordPress.

  • Use WordPress export to create xml and save locally.
  • Run the blog2md-master utility to convert local xml to markdown.
  • Run my Python 3 program fixMD to change Hugo front matter to 11ty front matter.
  • Move markdown files to 11ty posts sub directory.
  • Run “npx eleventy” to create static site.
  • Fix article links in index.html to use relative addressing.
  • Move files in ‘_site’ to my website blog sub directory.

FTP problem

Yesterday I FTP’d to my web host to delete a bunch of files. At some point the FTP program stopped working. I tried quitting and restarting. I could signon fine but when I tried to copy over a file I would get…

Command: USER billslit
Response: 331 User billslit OK. Password required
Command: PASS ****
Response: 530 Login authentication failed
Error: Critical error: Could not connect to server
Status: Disconnected from server

This error plagued me for a while. Id contact tech report and there response was “The IP has been unblocked now”.

I did some research and tried a suggestion of using “username@domain.com” for username in Filezilla, instead of just “username” which I always did up until now and that worked…for now!

Matrix/Riot

I’ve been hearing a lot about this lately. Sounds interesting and something to keep my eye on.

They say…

  • Matrix is an open standard for interoperable, decentralised, real-time communication over IP.
  • The simplest way to sign up and try Matrix out is to use Riot, a web-based client.

What a dumb name…Riot. The Riot client is going to be renamed matrix! Sounds like a good enough reason to wait to use it. I know that’s a dumb reason.

I did actually create a user/account. And lurked a while in the Matrix group. It was kind of uneventful. I guess that’s not a bad thing,

However I can’t seem to logon using my preferred browser Firefox. Only a third of he screen shows and it is blurred! I have no problem using Opera or Google Chrome.

Eleventy test blog

Well got the initial blog working. Apparently it sorts articles by the front matter date field which I was wondering about because the file names don’t provide a way to do this.

Python Markdown rewrite

Sure enough it was easier to rewrite in Python! It took less time to rewrite than documenting the Julia problem. Python realizes that sometimes a byte is just a byte, and it can also handle Unicode. And bonus…my memory of processing a directory, was using os.walk(), but found a much easier and straightforward way using os.listdir(dir).

In writing the program I found I needed to change the date format to yyyy-mm-dd. This led me to learning about the simple but useful .zfill() instruction. I had done this manually before. I also need to learn about python’s f-String formatting.