This site took 954 lines of code
I flipped my site again, and I flipped it back to 11ty...again. The repo is available here.
I'm much happier with the approach this time. I took the lessons from my NextJS + Contentlayer setup in my previous site to make Obsidian-sourced content work great for me. I don't have the same type safety that I had in the first "Obsidian as a CMS" approach, but I feel like I can accomplish much more with less code than I ever could with NextJS.
I added a script pnpm linecount
to count the source code lines, following the approach I used in 20k-lines-of-code. I was targeting a building a site in under 1,000 lines, and I hit it!
In 954 lines (as of this commit) I was able to include:
- search
- custom layouts
- theming
- SEO customization
I'm going to split out from this barebones version of this site and leave it as a template for others if they're interested. I still need to write a README though. Then I'm going to add some ✨pizazz✨ to my version of the site.
What I liked
- Includes match the mental model of building blog sites so much better than React components.
- Many fewer levels of abstraction than NextJS. All of the building logic is in the
eleventy.config.js
file. - Much more approachable for creative content sourcing. I had to transform the content twice to get NextJS to work nicely with Wiki-style links and images. In 11ty, I just have to transform it once, since
collections
and content sourcing life cycle hooks are core to the library.
What I did not like
- Nunjucks and Liquid are weirdly opinionated and strange to work with. For example, there is no Nunjucks
filter
for slicing an array, but there is aslice
filter that converts a one-dimensional array into an N-dimensional one. For a DSL based on JavaScript it sure seems hostile to JavaScript developers. The times I got the most frustrated developing this site were when I was trying to figure out how to do something that should be simple in Nunjucks, like have a filter take multiple arguments. How are there not good docs on this??? - I couldn't get my current editor, neovim, to recognize Liquid, Nunjucks, or respect the JSDocs syntax well. There seems to be no proper LSP implementations of the first two, and I don't understand what's up with the second one.
- Adding JS dependencies is kind of a free-for-all in 11ty, so I wasn't sure how to handle search, the only JS dependency I needed.