<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
  <title>Feed for jtle.dk</title>
  <id>https://jtle.dk</id>
  <updated>2025-04-30T21:26:00Z</updated>
  <link href="https://jtle.dk"></link>
  <author>
    <name>Julian Jørgensen</name>
    <email>post@jtle.dk</email>
  </author>
  <entry>
    <title>Rendering posts</title>
    <updated>2025-04-30T21:26:00Z</updated>
    <id>tag:,2025-04-30:/jtle.dk/post/2025-04-08-rendering-posts.html</id>
    <content type="html">&lt;![CDATA[&#xA;&#xA;&#xA;&lt;h1 class=&#34;title&#34;&gt;Rendering posts&lt;/h1&gt;&#xA;&lt;p class=&#34;info&#34;&gt;Date: Wednesday, 30. of April 2025&lt;/p&gt;&#xA;&lt;p class=&#34;description&#34;&gt;Setting up a simple blog with golang templating&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  I recently used the polarsteps thing on a vacation to Paris. Well&#xA;  actually I&#39;m on the way back from that.  I kind of like the idea of&#xA;  writing down what happened on a vacation with pictures and all, but&#xA;  polarsteps kind of has the annoying clause that they get a license&#xA;  to any pictures uploaded. Also they do not provide a rss/atom feed&#xA;  for people wanting to subscribe. Not cool.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  Well I have this website which I do pretty much nothing with, other&#xA;  than use it as a git host and a place to have my contact info here&#xA;  on the internet. Why not put it here (with some security maybe).&#xA;  Then I could also do an attempt at blogging (like thats going to&#xA;  happen, ever). I recently found this thing called DX-clusters which&#xA;  is really interesting, so it would be fun to write about that.&#xA;  &lt;i&gt;Hopefully no one will actually read it.&lt;/i&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  So how to do a blog?? Well I could use some fancy cms, but a blog is&#xA;  basicly just a simple html file together with some RSS/Atom feed&#xA;  thing. Maybe a listing on the index.html would also be nice. In this&#xA;  post I will kind of explain my KISS solution to this&#xA;  &#34;challenge&#34;. Pictures will be another thing, so at some point I will&#xA;  probably either write a new post or extend this one. Currently this&#xA;  will just serve to test that I can create text blogs.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Templating&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&#xA;  I don&#39;t do many personal programming projects. And when I do they&#xA;  often get stuck before I am able to finish them. This is partly&#xA;  because I have a much too large scope, so I lose interest really&#xA;  quickly.  But most often it is due to my inability to make&#xA;  choices. Like what language, stack, everything should I use.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  Sometimes I want to try something new, like create something in&#xA;  Haskell, or ocaml. But I quickly notice the very lacking ecosystem&#xA;  of those languages, making it a nightmare to do even basic things. I&#xA;  have found that if I cannot find a good time library (preferably in&#xA;  stdlib) then I should start looking at some other language.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  Rust is a very nice language and it has a nice time library, so many&#xA;  of my personal projects have used Rust. However, now I just get&#xA;  stuck selecting which library to use. I find this very hard in rust,&#xA;  because I need to figure out multiple different (rather complicated)&#xA;  libraries and how they fit together. While also fighting the rust&#xA;  typesystem, which I&#39;m not super duper friends with yet.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  Actually I have noticed that the projects I write in golang have the&#xA;  highest chances of success. The language itself is rather painful to&#xA;  write, but the massive stdlib means that all my decision problems&#xA;  have been solved before I even begin a project. Just do it the&#xA;  stdlib way, anything more advanced is probably not needed anyway.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  So this page has been rendered with the okay&#39;ish templating language&#xA;  included in golang. And not much else actually. Well I did do&#xA;  something kind of cursed.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Something kind of cursed&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&#xA;  When rendering out a page, I can those to write&#xA;  &lt;code&gt;{{ linkpost &amp;#34;post/2025-04-08-rendering-posts.html&amp;#34; }}&lt;/code&gt; which will render out the specific post in the served&#xA;  directory, and return the path where the post can be accessed. That&#xA;  means that I&#39;m calling the templating library while rendering&#xA;  templates. It seems to work just fine. I also added&#xA;  a &lt;code&gt;linkraw&lt;/code&gt; for raw files.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  Also while rendering a post, the engine is given a reference to a&#xA;  metadata object, which the template can override. So the template&#xA;  function &lt;code&gt;title&lt;/code&gt; will save that title in the metadata and&#xA;  return the given title to be used in the document itself (inside a&#xA;  h1 for example).&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  I think these hacks are okay, because the program is only run when i&#xA;  make changes to the git repo. And then the site is just build to a&#xA;  static set of files.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Generate Feeds&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&#xA;  I have no idea of RSS and ATOM feeds work. But I do know that I want&#xA;  them generated for this site. So I decided to use the gorilla feed&#xA;  library. Here content is put in the format agnostic &lt;code&gt;feed&lt;/code&gt;&#xA;  struct, which can then be rendered to both rss and atom. Pretty nice.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;  I decided to render all the posts two times, one with and without&#xA;  header and footer. That way I could include the content in the feed&#xA;  itself. I don&#39;t really expect to use this blog, but if I do then I&#xA;  should probably limit the number of posts included in the feed. Well&#xA;  that is a problem for later :-).&#xA;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;]]&gt;</content>
    <link href="https:/jtle.dk/post/2025-04-08-rendering-posts.html" rel="alternate"></link>
    <summary type="html">Setting up a simple blog with golang templating</summary>
    <author>
      <name>Julian Jørgensen</name>
      <email>post@jtle.dk</email>
    </author>
  </entry>
</feed>