New Site
Past Problems
After being fed up with the limitations and unneccessary complexity of WordPress I made the decision to rebuild this site as a static html. My issue using WP to manage the site was that all the complexity prevented me from implementing some seemingly simple features redesigns or eyecandy. Another thing was that all the content is stored in a database which makes it hard to port it to any other platform should the need arise.
Clean Slate
I had a vision in my head.
- Posts written as markdown files
- Simple home page to list all the posts
- Some CSS and JS
Thats it, this is all the "complexity" I need.
Building the HTML
Main challenge was to somehow convert the markdown files into html files and list them in the home page.
There are some existing static site builders available, but after trying some of them out, I felt that they would lead me into the same problems with over complexity which would limit the ease of modifications again.
So I decided to use python to create a build script from scratch because I knew it could get me to the result faster than using other languages or tools.
I know python is slow at many things but the current task of building HTML and copying some files would not have to be super quick. At least not when the number of posts is below a few hunderd or thousand. Just say NO! to premature optimisation.
The build process is quite simple:
- Scan through post markdown files
- Parse them into HTML
- Add web page header, footer and other common elements
- Copy any asset files that the post uses like images
- Generate homepage HTML to list the posts
The build script is not very long at the time of writing this. Here is the full code if anyone is interested:
Source
The posts are organized like this:
posts
|-post_0
|-index.md
|-resources
|-post_1
|-index.md
|-resources
etc...
Each post has its own resources folder for images and other assets. This makes each post an independed unit that can be handled without relying on any overarching system. This makes it easier to swap the build system in the future should I want to.
Benefits of Generating Static HTML
The best thing about building the site this way is that I am in full control, I know how everything works at every step on the way. This makes building any additional features more straightforward and most importantly fun.
Hosting a static HTML site is also very easy, it can be hosted pretty much anywhere and would even be functional when viewing it offline on a local machine.
Navigating a simple static web page feels really fast, there is just not much to load each time.
There is no unexpected behaviour, all the html that will be served is visible and not generated dynamically later on the server.
Downsides of Generating Static HTML
As with anything there are tradeoffs. Any dynamic changes to the web page in response to something can only be implemented clientside with javascript.
Some features like adding comments to posts cannot be implemented without using some 3rd party system that embeds via javascript.
Not being dynamic is kind of the point of the static HTML web site.
Personalize Your Web Page
Personal web page should be a place to have fun, create your own stuff the way you want however weird or inefficient it would be. Life is short, have fun!