thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

.txt posts

β€’ 248 words β€’ 2 min β€’ updated

Terence Eden:

A couple of years ago, I started serving my blog posts as plain text. Add .txt to the end of any URl and get a deliciously lo-fi, UTF-8, mono[chrome|space] alternative.

I like the idea! Using Hugo it’s quite straightforward to do so1:

diff
% git --no-pager show 590bb2751
[...]
diff --git config/_default/config.yml config/_default/config.yml
index c0ab59364..9b9e61d0e 100644
--- config/_default/config.yml
+++ config/_default/config.yml
@@ -65,15 +65,19 @@ disableKinds:
 # llms.txt BEGIN
 # layouts/_default/home.llms.txt
 mediaTypes:
   application/opml:
     suffixes:
       - opml
+  text/plain:
+    suffixes:
+      - txt
 outputFormats:
+  PlainText:
+    mediaType: text/plain
+    baseName: index
+    isPlainText: true
   OPML:
@@ -92,4 +96,5 @@ outputs:
     - OPML
   page:
     - HTML
+    - PlainText
 # llms.txt END
diff --git layouts/_default/baseof.html layouts/_default/baseof.html
index b164a9921..e806f53fa 100644
--- layouts/_default/baseof.html
+++ layouts/_default/baseof.html
@@ -20,6 +20,10 @@

   <link rel="canonical" href="{{ .Permalink }}" />

+  {{- with .OutputFormats.Get "PlainText" -}}
+  <link rel="alternate" type="text/plain" href="{{ .Permalink }}" title="{{ $.Title }}">
+  {{- end -}}
+
   {{- partial "style.html" . -}}

   {{- with .Site.Params.appleTouchIcon }}
diff --git layouts/_default/single.plaintext.txt layouts/_default/single.plaintext.txt
new file mode 100644
index 000000000..3b2f6453c
--- /dev/null
+++ layouts/_default/single.plaintext.txt
@@ -0,0 +1 @@
+{{ .RawContent }}

Example post.

Append /index.txt to any existing post to fetch its plain-text version.

While we’re here, /index.md also works.

  • β€” -

Update(2026-01-03): I removed .txt support. Only .md is left. Which is the most logical course of action, if you think about it. The Markdown format is more useful since it preserves the post structure.


  1. The original diff was slightly tweaked for readability. ↩︎