<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Feed for jtle.dk</title>
    <link>https://jtle.dk</link>
    <description></description>
    <managingEditor>post@jtle.dk (Julian Jørgensen)</managingEditor>
    <pubDate>Wed, 16 Apr 2025 21:00:00 +0000</pubDate>
    <lastBuildDate>Wed, 30 Apr 2025 21:26:00 +0000</lastBuildDate>
    <item>
      <title>Rendering posts</title>
      <link>https:/jtle.dk/post/2025-04-08-rendering-posts.html</link>
      <description>Setting up a simple blog with golang templating</description>
      <content:encoded><![CDATA[<![CDATA[


<h1 class="title">Rendering posts</h1>
<p class="info">Date: Wednesday, 30. of April 2025</p>
<p class="description">Setting up a simple blog with golang templating</p>

<p>
  I recently used the polarsteps thing on a vacation to Paris. Well
  actually I'm on the way back from that.  I kind of like the idea of
  writing down what happened on a vacation with pictures and all, but
  polarsteps kind of has the annoying clause that they get a license
  to any pictures uploaded. Also they do not provide a rss/atom feed
  for people wanting to subscribe. Not cool.
</p>

<p>
  Well I have this website which I do pretty much nothing with, other
  than use it as a git host and a place to have my contact info here
  on the internet. Why not put it here (with some security maybe).
  Then I could also do an attempt at blogging (like thats going to
  happen, ever). I recently found this thing called DX-clusters which
  is really interesting, so it would be fun to write about that.
  <i>Hopefully no one will actually read it.</i>
</p>

<p>
  So how to do a blog?? Well I could use some fancy cms, but a blog is
  basicly just a simple html file together with some RSS/Atom feed
  thing. Maybe a listing on the index.html would also be nice. In this
  post I will kind of explain my KISS solution to this
  "challenge". Pictures will be another thing, so at some point I will
  probably either write a new post or extend this one. Currently this
  will just serve to test that I can create text blogs.
</p>

<h2>Templating</h2>

<p>
  I don't do many personal programming projects. And when I do they
  often get stuck before I am able to finish them. This is partly
  because I have a much too large scope, so I lose interest really
  quickly.  But most often it is due to my inability to make
  choices. Like what language, stack, everything should I use.
</p>

<p>
  Sometimes I want to try something new, like create something in
  Haskell, or ocaml. But I quickly notice the very lacking ecosystem
  of those languages, making it a nightmare to do even basic things. I
  have found that if I cannot find a good time library (preferably in
  stdlib) then I should start looking at some other language.
</p>

<p>
  Rust is a very nice language and it has a nice time library, so many
  of my personal projects have used Rust. However, now I just get
  stuck selecting which library to use. I find this very hard in rust,
  because I need to figure out multiple different (rather complicated)
  libraries and how they fit together. While also fighting the rust
  typesystem, which I'm not super duper friends with yet.
</p>

<p>
  Actually I have noticed that the projects I write in golang have the
  highest chances of success. The language itself is rather painful to
  write, but the massive stdlib means that all my decision problems
  have been solved before I even begin a project. Just do it the
  stdlib way, anything more advanced is probably not needed anyway.
</p>

<p>
  So this page has been rendered with the okay'ish templating language
  included in golang. And not much else actually. Well I did do
  something kind of cursed.
</p>

<h2>Something kind of cursed</h2>

<p>
  When rendering out a page, I can those to write
  <code>{{ linkpost &#34;post/2025-04-08-rendering-posts.html&#34; }}</code> which will render out the specific post in the served
  directory, and return the path where the post can be accessed. That
  means that I'm calling the templating library while rendering
  templates. It seems to work just fine. I also added
  a <code>linkraw</code> for raw files.
</p>

<p>
  Also while rendering a post, the engine is given a reference to a
  metadata object, which the template can override. So the template
  function <code>title</code> will save that title in the metadata and
  return the given title to be used in the document itself (inside a
  h1 for example).
</p>

<p>
  I think these hacks are okay, because the program is only run when i
  make changes to the git repo. And then the site is just build to a
  static set of files.
</p>

<h2>Generate Feeds</h2>

<p>
  I have no idea of RSS and ATOM feeds work. But I do know that I want
  them generated for this site. So I decided to use the gorilla feed
  library. Here content is put in the format agnostic <code>feed</code>
  struct, which can then be rendered to both rss and atom. Pretty nice.
</p>

<p>
  I decided to render all the posts two times, one with and without
  header and footer. That way I could include the content in the feed
  itself. I don't really expect to use this blog, but if I do then I
  should probably limit the number of posts included in the feed. Well
  that is a problem for later :-).
</p>



]]]]><![CDATA[>]]></content:encoded>
      <author>Julian Jørgensen</author>
      <pubDate>Wed, 30 Apr 2025 21:26:00 +0000</pubDate>
    </item>
  </channel>
</rss>