Adding native image lazy-loading to Ghost with a Cloudflare Worker
In my recent post about Street Photography in South Korea, I embedded many high-res pictures. The total size of the page is about 40 MB, which is a bit much to load right away.
In my recent post about Street Photography in South Korea, I embedded many high-res pictures. The total size of the page is about 40 MB, which is a bit much to load right away.
After my recent relooking, I finally took the time to add syntax highlighting for code snippets.
While Ghost doesn’t support code syntax highlighting out the box, it lays down the groundwork for it.
As of now, I am still running my custom Ghost theme, although I plan on changing it soon. (Edit: I did).
It’s open-source and available on GitHub at angristan/Casper-XYZ. I update it regularly and keep it synced with the original Casper theme.
A few months ago, the Ghost team came up with action-deploy-theme, an GitHub action to deploy a theme to a Ghost website automatically, right from GitHub!
I have been enjoying it for a while now, so let me share how it works.
I’ve never used date in my blog posts URLs because I thought it looked nicer and was better for SEO.
Recently, I changed my mind and I find it better to have the date in the permalink. Not necessarily as precise as to put the day, but as least the year and month.
What I want to achieve is this:
https://angristan.xyz/understand-k8s/
->
https://angristan.xyz/2020/01/understand-k8s/
Ghost once had a toggle in the settings to enable dated permalinks, but it’s gone now and it’s off by default. However, it still does support it thanks to dynamic routing, which allows creating routes however you like through a YAML file.
I’ve been using Ghost with SQLite for a year and a half and I haven’t had any issues related to SQLite at all. I would even say this is a very good choice for Ghost and I realize now that I’ve made a post about it.
I want to switch back to MySQL because I feel more confident using it. Especially for backups.
My current setup is a LXD host server with a bunch of containers managed by Ansible. My Ghost container has access to an existing MySQL container, so I created a new database in a few seconds. All my backup workflow is already functional for MySQL, so switching really does not cost me much. That may not be the case for everyone though! If your Ghost website is hosted on a single server, SQLite is still a good choice.
Ever since I started this blog I have been using Nginx as a reverse proxy for Ghost.
Ghost is in a kind of weird place between real static and headless CMS like Hugo or Jekyll and fully-fledged CMS like WordPress. Ghost is a Node.js program based on Express that binds to a port and listen to HTTP requests, so it’s not deployable like a static website with only static files.
In my first post I said I installed Ghost with ghost-cli
, the classic way. I did also say that I wanted to run it in Docker but that I didn’t know Docker enough to do it.
In fact, I tried to set up Ghost in Docker a few times while being bored at school, but I didn’t succeed, so it ended up like it is now.
For the past week though, I’ve been learning and using Docker a lot, and finally moved a dozen services into containers.
In my first post, I said that I set up my Ghost blog with a MySQL database.
Why is that? Because ghost-cli
wants you to use a MySQL database and I happened to have a MariaDB server on my VM and so I just added another database to it
However, Ghost supports SQlite as a storage backend. In fact, SQLite can handle more load than this blog could ever have, considering I use Nginx cache on my reverse proxy. In the end, the database is only used when I do stuff in the back-office, which is very light on the database.
Note
Here we go!
I’m Stanislas, a French 18 years old tech enthusiast.
My areas of interest are:
I currently studying at ESGI, a French IT school, and I work at a French web hosting company.
More on the about page
I run a French blog, angristan.fr, since 2014, and over the years I began to read and listen to more and more English resources, and by now I think it’s my main language, except that I still speak French IRL, and I’m not really fluent in terms of writing and speaking. As such, I’ll ask you to bear with me as I’ll probably do some (many?) mistakes.