Going Indie
I finally got around to delete my GitHub Pages site and set up my own site. Why? Because I want to keep the web open and free for everyone.
A few years ago I switched from a self-hosted site to GitHub Pages. The reason was that it was convenient. I could just push my statically generated site to a git repository, and GitHub Pages would host it for me, fast, reliably, and free.
Convenient indeed, but the flipside is that I am part of making the web more centralized by using GitHub 1. Both in terms of network centralization but also in terms of control and information. I do not like that the big tech companies are controlling more and more of the web, and by it, our lives. I never have, but convenience is a powerful thing. 1. Ploum recently wrote an article on How Github monopoly is destroying the open source ecosystem I think there are a lot of valid points in that article.
I am also tired of being fed by the corporations and their algorithms. Sure, I have found great articles, music, and videos by relying on recommendations and social media. But I also feel that more and more of the content i consume is directed, overly commercial, and the same stuff over and over again.
So recently I tried to be more conscious about what I consume online, and part of that is that I have been surfing the indie webs, and I enjoyed it a lot!
It is not that I have been unaware of the indie web, I have just been too comfortable using social media, Hacker News2 and Lobsters3. 2. I am not claiming that HackerNews is corporate! I still visit every day!
Before we drift off into what I have been up to during Christmas, I want to mention two sites in particular that I think you should check out, I'll wait here. 3. I am only lurking here, if I have any reader that wants to invite me - I would be happy 🤗. https://lobste.rs/
- Ye Olde Blogroll - A humanly curated list of 1080 fine personal & independent blogs and sites that are updated regularly.
- People and Blogs - A site and newsletter presenting bloggers from all over the world, in all topics. Well worth subscribing to.
Rolling my own
I am not a frequent writer, which is pretty obvious when you look at the timestamps on my articles. I don't get that many visitors so my needs are quite modest. I do not need a CDN, I do not need a CMS 4, and I do not need a newsletter.
4. I considered using Ghost just because it looks so polished, they contribute to open source software and seem to be nice people. But with my modest site I could not motivate the cost (I want to have a custom theme).
Modest needs, aversion to the corporate web, and a desire to tinker?
I did what any reasonable person would do, I poured myself a cup of coffee and started writing code.
Well, not exactly, first I made a list of requirements – as you do.
- I wanted to keep my existing articles, which currently are in Markdown format from when I used Hugo.
- Look and feel are important. I am certainly no designer, but I like to do my own layout.
- I want to be able to add things like a guestbook, visitor counter, etc. Fun stuff from the old days.
- I want to host it myself, preferably in Sweden, or at least in the EU.
Equipped with my now cold brew, I wrote a Scala service that reads my Markdown articles during boot and serves them server side rendered. I did not use any web framework, I made my own simple one.
Hold on, let's rewind. Scala?
Yes! Scala is a fine language! I used it professionally a few years ago, I liked it a lot and have been missing it since. I think it has the perfect balance between functional and object-oriented programming. It has reasonable syntax and the JVM ecosystem is great.
A few months ago I stumbled upon a small web framework named sharaf. At that time
I was looking for a web framework that did not use Future, async, or any sort of effect-system. I wanted something
small and simple.
While claiming to be minimal, Sharaf is too big for my needs (with features like JSON, forms, etc.), but it has support for using Helidon as the HTTP server. That caught my interest. So I made my own small thing using Helidon as well. I did not use any code, I just took inspiration on how it integrated with Helidon – so thank you for that Sharaf.
Once I had some basic routing and serving of static files, I wrote a small snippet of code that would read the existing Hugo-formatted Markdown files and convert them to HTML using flexmark-java. First, I tried to use scalamd but that did not work with Markdown tables and some code blocks did not render properly.
Where's the JavaScript?
There is none. There is not even any HTML5!
5. Ever since I came across Elm, I’ve thought that templating languages are an imperfect solution. Why glue together HTML and JavaScript using expressions hidden in an HTML attribute, when instead you can just use a general purpose language to generate HTML?
In my case, I use ScalaTags to generate each page server-side. As I said, my site does not get a lot of traffic, so I don't mind generating the page for each request (the Mardown content is just parsed once though).
Here is an example of how a page is implemented:
class ArticleListPage(articles: Articles) extends PageLayout:
val pageTitle = "Articles at Markus Eliasson"
override def render(): String =
this.root().render
private def root() =
page(
article(
h1("Articles", dot()),
allArticles()
)
)
private def allArticles() =
div(`class` := "list",
articles.published.map { article =>
a(`class` := "list-item hover-feedback", href := s"/article/${article.slug}",
span(article.title),
hr(),
time(article.shortDate)
)
}
)
The HTML elements are implemented as functions in ScalaTags. E.g., the anchor element a has the attributes
class and href set and then three children elements.
I really enjoy writing web pages like this! It is clean, type-safe, and easy to compose and to implement "components" using regular functions.
On the turntable
I do not want my site to just be a few articles, I want to make it more personal. I listen to a lot of music, and I decided to add a feature where I can list the albums I currently listen to.
For now, it is just a single file in TOML format that contains the list of albums. Similar to the articles, it is read on boot and then rendered using a similar page as previously described.
This might be changed into a feature where I keep track of my vinyl collection instead of using Discogs. However, for now it is just a list of albums that I am listening to, and hopefully I will update it regularly.
Kubernetes? No. Docker? No.
I bought (rent?) a VPS at this Swedish company named Glesys. They use renewable energy, care about privacy, follow European data laws, and have reasonable prices.
Using Linux, of course, I just run the service on the locally installed OpenJRE (controlled by systemd).
I use Caddy as a reverse proxy with built-in TLS support.
I do not even have a CI/CD pipeline, I just build a fat JAR locally and scp it to the server. Like a cowboy.
That is pretty much it for now, next up is to add a guestbook and see if I can get at least one non-spam comment.
Convenience and vanity
I still use GitHub for my code, I am considering moving to Codeberg6 or just host a git-server myself. My hobby projects do not have any contributors really, and I just use GitHub for show-off. Vanity, I know. 6. I recently learned that Codeberg only has two part-time employees. That is crazy!
Hopefully, this is just the beginning of my journey back7 to the indie web. I have had lots of fun writing this site. There is a liberating feeling when you write your own server just the way you want it, not building a product, a framework or hosting something professionally. If it breaks, or I grow tired of it, I can just pour myself another cup of coffee and start over. 7. My first site was an anarchist site at Geocities, at the end of the 90s =)
Thank you for reading! Please reach out about what you think of my site, or the indie web in general.