summaryrefslogtreecommitdiff
path: root/posts/20221024-static-site-generators.md
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2022-10-24 22:14:06 -0600
committerAlexis Hovorka <[email protected]>2022-10-24 22:14:06 -0600
commit634301e45433bf06fcdae500d51275677e568adb (patch)
treef7a5a3051648322c6243420667b120440e7fa1df /posts/20221024-static-site-generators.md
Initial commit
Diffstat (limited to 'posts/20221024-static-site-generators.md')
-rw-r--r--posts/20221024-static-site-generators.md82
1 files changed, 82 insertions, 0 deletions
diff --git a/posts/20221024-static-site-generators.md b/posts/20221024-static-site-generators.md
new file mode 100644
index 0000000..a8a3740
--- /dev/null
+++ b/posts/20221024-static-site-generators.md
@@ -0,0 +1,82 @@
+---
+date: 2022-10-24
+title: Static Site Generators
+---
+
+So my current fascination is static site generators---programs that you can
+feed, for example, a set of plain-text blog files, and have them rendered
+into a folder full of "static" HTML files that can be deployed directly to a
+webserver with no "moving parts."
+
+Websites made of static files are nice, both because those files are very easy
+to cache for a significant speed up at load time, and because the number of
+places security holes could be hiding is greatly reduced. This blog uses an SSG
+called [Eleventy.js](https://www.11ty.dev/).
+
+## Why don't you just use \_\_\_\_\_\_?
+
+I didn't want to use a standard blog platform for a couple of reasons: first,
+hosting it myself gives me ultimate control of the content I produce, forever.
+I'm not interested in having someone else monetize my work with ads or
+paywalls. I don't need the extra features those platforms would present to
+me---I'm not worried about SEO or growing my readership; I have ADHD, and if
+I'm honest with myself, I'm not sure this attempt at a blog will last any
+longer than the previous ones.
+
+Second, I like making things myself, even when I'm kinda sorta reinventing the
+wheel. It may take more time, but I always give familiar skills a good stretch,
+and I almost always learn something new. I find the process kinda, like...
+meditative, and fulfilling, and I *love* how what I produce at the end fits me
+and my process like a glove. Being able to write in Markdown in vim and save my
+entire site in a [self-hosted Git
+repository](https://git.alexishovorka.com/blog.git/) feels extremely comfy to
+me.
+
+And finally third, which is sort of a fusion of the previous two: doing it
+myself lets me experiment much more easily. Adding a light/dark mode switch
+like the one in the top right corner to a standard-issue blog template would
+have taken me a lot more work. But since I designed this entire site from
+scratch, it only took me a handful of lines of code that go right where I want
+to put them. And all the little icons around the site---it was fun playing
+around with CSS shapes again, instead of just slapping down SVGs or PNGs or
+whatever.
+
+## My Setup
+
+The best description of my setup would be [the actual
+code](https://git.alexishovorka.com/blog.git/) since it's bound to evolve at
+least somewhat from anything I could write here. I'll go over some of the
+trickier bits here though.
+
+The cleanest way I found to set a default page template in Eleventy.js was to
+create a file at `globals/layout.js` which masks what would otherwise have been
+generated by the system up to that point. At time of writing, it's pretty
+short, just one line:
+
+```js
+module.exports = "post.njk";
+```
+
+`post.njk` is the layout template file for the page for an individual post.
+
+The same goes for the default page titles inside `globals/eleventyComputed.json`:
+
+```json
+{
+ {% raw %}"pageTitle": "{{ title | safe }} – {{ metadata.title | safe }}"{% endraw %}
+}
+```
+
+Figuring out the most optimal way to set up the history pages took a little
+doing. What I've settled on for now is putting them under `/archive/` with
+`/archive/1/` being blurbs from the first five posts (once I've written that
+many, of course).
+
+I haven't actually made the little heart-shaped "Like Post" button at the
+bottom work yet, but the current plan is to make a little script that logs the
+post's title to a text file and returns a 204, then when I want to get like
+counts I can just do `sort likes.txt | uniq -c`. No funky injectable
+databases---if there's spam, I can just delete the lines from the file and
+maybe insert a little check to drop entries if there are any obvious patterns.
+
+That's it for now, I guess? See ya :wave: