<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>hugo on nocturne</title><link>https://tiennm99.github.io/nocturne/tags/hugo/</link><description>Recent content in hugo on nocturne</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 20 Aug 2026 19:30:00 +0700</lastBuildDate><atom:link href="https://tiennm99.github.io/nocturne/tags/hugo/index.xml" rel="self" type="application/rss+xml"/><item><title>Hugo's built-in shortcodes</title><link>https://tiennm99.github.io/nocturne/2026/08/20/shortcodes/</link><pubDate>Thu, 20 Aug 2026 19:30:00 +0700</pubDate><guid>https://tiennm99.github.io/nocturne/2026/08/20/shortcodes/</guid><description>&lt;p&gt;A shortcode is a small template you call from the middle of Markdown, written as &lt;code&gt;{{&amp;lt; name params &amp;gt;}}&lt;/code&gt;. Hugo ships a set of them, and this post tries each one in turn. Every section shows the source first and the result right after.&lt;/p&gt;
&lt;p&gt;The shortcodes that embed third-party content (YouTube, Vimeo, X, Instagram) are left out: they pull in code from someone else&amp;rsquo;s servers as soon as the page opens, and a demo site should not push that on its visitors.&lt;/p&gt;
&lt;h2 id="why-nocturne-has-no-shortcodes-of-its-own"&gt;Why nocturne has no shortcodes of its own&lt;/h2&gt;&lt;p&gt;A post that uses a theme&amp;rsquo;s own shortcode is tied to that theme: switch themes and the build fails on that post, and you are left fixing files one by one. nocturne wants your content to stay plain Markdown that reads fine on GitHub, in your editor, and wherever you move it next.&lt;/p&gt;
&lt;p&gt;Everything the theme does to your content goes through render hooks instead: captioned images, GitHub-style alerts, scrolling tables, links to &lt;code&gt;.md&lt;/code&gt; files. You write standard Markdown and the theme handles the presentation. If you really need a shortcode, put it in your site&amp;rsquo;s &lt;code&gt;layouts/_shortcodes/&lt;/code&gt; — it belongs to your content, not to the theme.&lt;/p&gt;
&lt;h2 id="figure"&gt;figure&lt;/h2&gt;&lt;p&gt;An image with a caption and a link, written as a shortcode rather than Markdown image syntax:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-markdown" data-lang="markdown"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{&amp;lt; figure
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; src=&amp;#34;https://tiennm99.github.io/nocturne/img/tinh-tu-static.png&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; alt=&amp;#34;A test card with six vertical colour bars&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; caption=&amp;#34;A test card, stored in the static folder.&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; link=&amp;#34;https://en.wikipedia.org/wiki/Test_card&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;}}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;figure&gt;&lt;a href="https://en.wikipedia.org/wiki/Test_card"&gt;&lt;img src="https://tiennm99.github.io/nocturne/img/tinh-tu-static.png"
 alt="A broadcast test card: six vertical bars in red, green, yellow, blue, magenta and cyan, crossed by a diagonal rainbow streak"&gt;&lt;/a&gt;&lt;figcaption&gt;
 &lt;p&gt;A test card, stored in the static folder. Click the image to read about test cards.&lt;/p&gt;
 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;For an image in the bundle, the Markdown syntax &lt;code&gt;![alt](image.jpg &amp;quot;caption&amp;quot;)&lt;/code&gt; produces the same &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; and adds a &lt;code&gt;srcset&lt;/code&gt; on top; see &lt;a href="https://tiennm99.github.io/nocturne/2026/06/12/hinh-anh/"&gt;the post about images&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Sites in a subfolder&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;&lt;code&gt;figure&lt;/code&gt; looks for &lt;code&gt;src&lt;/code&gt; in the bundle and then in &lt;code&gt;assets/&lt;/code&gt;, but it does not add the base path to files in &lt;code&gt;static/&lt;/code&gt;. The demo lives under &lt;code&gt;/nocturne/&lt;/code&gt;, so &lt;code&gt;src=&amp;quot;/img/tinh-tu-static.png&amp;quot;&lt;/code&gt; would point outside the site; that is why the example above uses a full URL. Markdown image syntax has no such problem, because the theme&amp;rsquo;s render hook adds the base path for you.&lt;/p&gt;
&lt;/blockquote&gt;&lt;h2 id="details"&gt;details&lt;/h2&gt;&lt;p&gt;A collapsible block whose content is still written in Markdown:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-markdown" data-lang="markdown"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{&amp;lt; details summary=&amp;#34;Show the top of hugo.yaml&amp;#34; &amp;gt;}}
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{&amp;lt; /details &amp;gt;}}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;details&gt;
 &lt;summary&gt;Show the top of hugo.yaml&lt;/summary&gt;
 &lt;p&gt;The first three lines of &lt;code&gt;hugo.yaml&lt;/code&gt; for an English site using nocturne:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;nocturne&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;languageCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;en&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;defaultContentLanguage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;en&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The full required block is in the &lt;a href="https://github.com/tiennm99/nocturne/blob/main/docs/config.md" rel="noopener noreferrer"&gt;configuration docs&lt;/a&gt;.&lt;/p&gt;
&lt;/details&gt;

&lt;p&gt;Add &lt;code&gt;open=true&lt;/code&gt; to have the block open when the page loads.&lt;/p&gt;
&lt;h2 id="highlight"&gt;highlight&lt;/h2&gt;&lt;p&gt;The same highlighter as fenced code blocks, with the options passed as shortcode parameters:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-markdown" data-lang="markdown"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{&amp;lt; highlight go &amp;#34;linenos=inline,hl_lines=3&amp;#34; &amp;gt;}}
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{&amp;lt; /highlight &amp;gt;}}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;func&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;	&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line hl"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;		&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#34;friend&amp;#34;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;	&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;5&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;	&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#34;Hello, &amp;#34;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;6&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In a post, a fenced block such as &lt;code&gt;```go {hl_lines=3}&lt;/code&gt; is tidier; &lt;code&gt;highlight&lt;/code&gt; earns its keep when the code sits inside a template or another shortcode.&lt;/p&gt;
&lt;h2 id="qr"&gt;qr&lt;/h2&gt;&lt;p&gt;Generates a QR code at build time, as a PNG served with the site:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-markdown" data-lang="markdown"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{&amp;lt; qr text=&amp;#34;https://tiennm99.github.io/nocturne/&amp;#34; alt=&amp;#34;...&amp;#34; /&amp;gt;}}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;img src="https://tiennm99.github.io/nocturne/qr_bab63491ad8219.png" width="148" height="148" alt="QR code linking to the nocturne demo site"&gt;
&lt;p&gt;Scan it with your phone to open this demo.&lt;/p&gt;
&lt;h2 id="param"&gt;param&lt;/h2&gt;&lt;p&gt;Reads a parameter, looking in the page&amp;rsquo;s front matter first and then in the site&amp;rsquo;s &lt;code&gt;params&lt;/code&gt;:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th style="text-align: left"&gt;Source&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Result&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;{{&amp;lt; param &amp;quot;author&amp;quot; &amp;gt;}}&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Your Name&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;{{&amp;lt; param &amp;quot;toc.minWordCount&amp;quot; &amp;gt;}}&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;400&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;{{&amp;lt; param &amp;quot;description&amp;quot; &amp;gt;}}&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;figure, details, highlight, qr, param, ref and relref — the shortcodes Hugo ships with, all working in nocturne without the theme adding any of its own.&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;&lt;p&gt;The last row is a small trap: the site has &lt;code&gt;params.description&lt;/code&gt;, but this post has a &lt;code&gt;description&lt;/code&gt; in its front matter too, so &lt;code&gt;param&lt;/code&gt; returns the post&amp;rsquo;s own. The dot in &lt;code&gt;toc.minWordCount&lt;/code&gt; reaches into a nested parameter.&lt;/p&gt;
&lt;h2 id="ref-and-relref"&gt;ref and relref&lt;/h2&gt;&lt;p&gt;These two look up a page by its path under &lt;code&gt;content/&lt;/code&gt; and return its URL. If the page does not exist the build fails, so a broken link can never go live.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ref&lt;/code&gt; returns the full URL: &lt;code&gt;https://tiennm99.github.io/nocturne/2026/07/03/khoi-code/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;relref&lt;/code&gt; returns the path without the host: &lt;code&gt;/nocturne/2026/07/03/khoi-code/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most of the time they sit inside a Markdown link, optionally with a &lt;code&gt;#&lt;/code&gt; fragment pointing at a heading:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-markdown" data-lang="markdown"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[&lt;span class="nt"&gt;A Markdown tour&lt;/span&gt;](&lt;span class="na"&gt;{{&amp;lt; relref &amp;#34;/post/2026/05/07/sample&amp;#34; &amp;gt;}}&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[&lt;span class="nt"&gt;its Alerts section&lt;/span&gt;](&lt;span class="na"&gt;{{&amp;lt; relref &amp;#34;/post/2026/05/07/sample#alerts&amp;#34; &amp;gt;}}&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The result: &lt;a href="https://tiennm99.github.io/nocturne/2026/08/20/shortcodes//nocturne/2026/05/07/sample/"&gt;A Markdown tour&lt;/a&gt; and &lt;a href="https://tiennm99.github.io/nocturne/2026/08/20/shortcodes//nocturne/2026/05/07/sample/#alerts"&gt;its Alerts section&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In nocturne, a Markdown link straight to the file, such as &lt;code&gt;[post](/post/2026/05/07/sample/index.md)&lt;/code&gt;, gives the same URL without any shortcode; &lt;code&gt;ref&lt;/code&gt; and &lt;code&gt;relref&lt;/code&gt; still pay off when you want the build to stop the moment the target page disappears.&lt;/p&gt;</description></item><item><title>A Markdown tour</title><link>https://tiennm99.github.io/nocturne/2026/05/07/sample/</link><pubDate>Thu, 07 May 2026 19:00:00 +0700</pubDate><guid>https://tiennm99.github.io/nocturne/2026/05/07/sample/</guid><description>&lt;p&gt;This post is a short walk through Markdown: each section uses one piece of syntax and shows how nocturne renders it. To compare with the source, follow the edit link at the end of the page — it opens this very &lt;code&gt;index.en.md&lt;/code&gt; on GitHub.&lt;/p&gt;
&lt;p&gt;The post is long enough to get a table of contents. On a wide screen it sits beside the text and highlights the section you are reading; on a phone it tucks in above the content.&lt;/p&gt;
&lt;h2 id="text-and-links"&gt;Text and links&lt;/h2&gt;&lt;p&gt;A plain sentence can hold &lt;strong&gt;bold&lt;/strong&gt;, &lt;em&gt;italics&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;both at once&lt;/strong&gt;&lt;/em&gt;, &lt;del&gt;a dropped idea&lt;/del&gt; and &lt;code&gt;inline code&lt;/code&gt; such as &lt;code&gt;hugo server --buildDrafts&lt;/code&gt;. Keyboard shortcuts use an HTML tag: &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;C&lt;/kbd&gt;.&lt;/p&gt;
&lt;p class="lead"&gt;This paragraph carries a &lt;code&gt;lead&lt;/code&gt; class, added by a Markdown attribute on the line right below it. The theme does not style that class, but it is in the HTML for your own CSS to pick up.&lt;/p&gt;
&lt;p&gt;External links such as &lt;a href="https://gohugo.io/documentation/" rel="noopener noreferrer"&gt;Hugo&amp;rsquo;s documentation&lt;/a&gt; get &lt;code&gt;rel=&amp;quot;noopener noreferrer&amp;quot;&lt;/code&gt; added. Internal links can point straight at a Markdown file: &lt;a href="https://tiennm99.github.io/nocturne/2026/06/12/hinh-anh/"&gt;the post about images&lt;/a&gt; turns into that post&amp;rsquo;s real URL, and &lt;a href="https://tiennm99.github.io/nocturne/2026/07/03/khoi-code/#line-numbers"&gt;the line numbers section of the code post&lt;/a&gt; keeps its &lt;code&gt;#line-numbers&lt;/code&gt; fragment. Change your URL scheme later and these links still work.&lt;/p&gt;
&lt;h3 id="a-heading-with-its-own-class" class="special"&gt;A heading with its own class&lt;/h3&gt;&lt;p&gt;The heading above has a &lt;code&gt;{.special}&lt;/code&gt; attribute. The class is kept and the &lt;code&gt;id&lt;/code&gt; is still generated, so the table of contents and the &lt;code&gt;#&lt;/code&gt; that shows on hover keep working.&lt;/p&gt;
&lt;h2 id="lists-and-to-dos"&gt;Lists and to-dos&lt;/h2&gt;&lt;p&gt;An unordered list, nested:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Content
&lt;ul&gt;
&lt;li&gt;Posts&lt;/li&gt;
&lt;li&gt;About page&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Look and feel
&lt;ul&gt;
&lt;li&gt;Light and dark modes&lt;/li&gt;
&lt;li&gt;A typeface that handles Vietnamese well&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An ordered list, numbered per level:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a folder for the post.&lt;/li&gt;
&lt;li&gt;Write &lt;code&gt;index.md&lt;/code&gt;, then add the &lt;code&gt;index.en.md&lt;/code&gt; translation next to it.
&lt;ol&gt;
&lt;li&gt;Keep the date, category and tags the same.&lt;/li&gt;
&lt;li&gt;Translate the title, description and body.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;hugo server&lt;/code&gt; and read it through once.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A task list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Write a draft&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Add images to the bundle&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Ask a friend to proofread&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Publish&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="definition-lists"&gt;Definition lists&lt;/h3&gt;&lt;dl&gt;
&lt;dt&gt;Bundle&lt;/dt&gt;
&lt;dd&gt;A folder holding &lt;code&gt;index.md&lt;/code&gt; together with the post&amp;rsquo;s images and other files.&lt;/dd&gt;
&lt;dt&gt;Front matter&lt;/dt&gt;
&lt;dd&gt;The YAML block at the top of the file, where the title, date, tags and categories live.&lt;/dd&gt;
&lt;dt&gt;Render hook&lt;/dt&gt;
&lt;dd&gt;A small template that decides how Hugo outputs images, links, headings, tables and blockquotes.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id="tables"&gt;Tables&lt;/h2&gt;&lt;p&gt;Colons in the separator row set each column&amp;rsquo;s alignment:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th style="text-align: left"&gt;Syntax (left)&lt;/th&gt;
 &lt;th style="text-align: center"&gt;Result (centre)&lt;/th&gt;
 &lt;th style="text-align: right"&gt;Characters (right)&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;**bold**&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: center"&gt;&lt;strong&gt;bold&lt;/strong&gt;&lt;/td&gt;
 &lt;td style="text-align: right"&gt;8&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;*italic*&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: center"&gt;&lt;em&gt;italic&lt;/em&gt;&lt;/td&gt;
 &lt;td style="text-align: right"&gt;8&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;~~struck~~&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: center"&gt;&lt;del&gt;struck&lt;/del&gt;&lt;/td&gt;
 &lt;td style="text-align: right"&gt;10&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;`code`&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: center"&gt;&lt;code&gt;code&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: right"&gt;6&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;&lt;h3 id="a-wide-table"&gt;A wide table&lt;/h3&gt;&lt;p&gt;A table with many columns sits in a horizontally scrolling region, so it never stretches the page on a phone. The region takes focus, so keyboard users can scroll it with the arrow keys.&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th style="text-align: left"&gt;Format&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Extension&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Theme handling&lt;/th&gt;
 &lt;th style="text-align: center"&gt;WebP &lt;code&gt;srcset&lt;/code&gt;&lt;/th&gt;
 &lt;th style="text-align: center"&gt;&lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt;&lt;/th&gt;
 &lt;th style="text-align: center"&gt;Animation&lt;/th&gt;
 &lt;th style="text-align: center"&gt;Transparency&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Good for&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;JPEG&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;.jpg&lt;/code&gt;, &lt;code&gt;.jpeg&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Resized&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Photos and detailed pictures&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;PNG&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;.png&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Resized&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Screenshots and flat artwork&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;WebP&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;.webp&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Resized&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Possible&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Most things on today&amp;rsquo;s web&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;SVG&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;.svg&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Served as is&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Possible&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Icons, diagrams, logos&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;GIF&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;.gif&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Served as is&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: center"&gt;No&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: center"&gt;Yes&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Short loops with few colours&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;&lt;h4 id="when-to-reach-for-a-table"&gt;When to reach for a table&lt;/h4&gt;&lt;p&gt;Tables suit data you compare across rows and columns. For steps done one after another, an ordered list reads better on a narrow screen.&lt;/p&gt;
&lt;h2 id="quotes"&gt;Quotes&lt;/h2&gt;&lt;p&gt;A plain blockquote, no alert styling:&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;A day&amp;rsquo;s travel brings a basketful of wisdom.&lt;/p&gt;
&lt;p&gt;— Vietnamese proverb&lt;/p&gt;

&lt;/blockquote&gt;&lt;h2 id="alerts"&gt;Alerts&lt;/h2&gt;&lt;p&gt;All five GitHub alert types are here. Their default titles follow the page language.&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;Background a reader should know, even when skimming.&lt;/p&gt;
&lt;/blockquote&gt;&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;Run &lt;code&gt;hugo server --navigateToChanged&lt;/code&gt; and the browser jumps to the page you just edited.&lt;/p&gt;
&lt;/blockquote&gt;&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;A translation lives next to the original in the same bundle, named &lt;code&gt;index.en.md&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;Hugo does not merge &lt;code&gt;markup&lt;/code&gt; from a theme, so copy the required config block into your site&amp;rsquo;s &lt;code&gt;hugo.yaml&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Caution&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;&lt;code&gt;draft: true&lt;/code&gt; keeps a post out of the build, but the file is still in your repository. If the repository is public, anyone can read it.&lt;/p&gt;
&lt;/blockquote&gt;&lt;p&gt;Right after &lt;code&gt;[!TIP]&lt;/code&gt; you can write your own title in place of the default one:&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Keep it short&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;An alert works best with a sentence or two. Any longer and it probably wants a section of its own.&lt;/p&gt;
&lt;/blockquote&gt;&lt;h2 id="footnotes"&gt;Footnotes&lt;/h2&gt;&lt;p&gt;Hugo turns Markdown into HTML with Goldmark&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;. A footnote can have a name instead of a number&lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;, and its text always gathers at the end of the post, with an arrow back to where you were reading.&lt;/p&gt;
&lt;h2 id="collapsible-content"&gt;Collapsible content&lt;/h2&gt;&lt;p&gt;The site turns on &lt;code&gt;markup.goldmark.renderer.unsafe&lt;/code&gt;, so hand-written HTML goes straight to the page. A &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; tag makes a block that opens and closes without any JavaScript:&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;Why does every post have two files?&lt;/summary&gt;
&lt;p&gt;Each post is a bundle. &lt;code&gt;index.md&lt;/code&gt; is the Vietnamese version, the site&amp;rsquo;s default language; &lt;code&gt;index.en.md&lt;/code&gt; is the English one. Hugo pairs the two files as translations, and the language picker jumps straight to the matching post.&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;Hugo also has a &lt;code&gt;details&lt;/code&gt; shortcode that does the same job; see &lt;a href="https://tiennm99.github.io/nocturne/2026/08/20/shortcodes/"&gt;the shortcode post&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;The rule above is three dashes, &lt;code&gt;---&lt;/code&gt;, on a line of their own between blank lines. This post was edited after it went out, so an updated date shows under the title.&lt;/p&gt;
&lt;div class="footnotes" role="doc-endnotes"&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;Goldmark is a Markdown parser written in Go that follows the CommonMark spec.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:2"&gt;
&lt;p&gt;The name only exists in the source; on the page, footnotes are still numbered in the order they appear.&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description></item><item><title>Writing your own Hugo theme</title><link>https://tiennm99.github.io/nocturne/2026/02/14/tu-viet-theme/</link><pubDate>Sat, 14 Feb 2026 21:00:00 +0700</pubDate><guid>https://tiennm99.github.io/nocturne/2026/02/14/tu-viet-theme/</guid><description>&lt;p&gt;A month after &lt;a href="https://tiennm99.github.io/nocturne/2026/01/10/ke-hoach-dau-nam/"&gt;the new-year plan&lt;/a&gt;, &lt;code&gt;nocturne&lt;/code&gt; is good enough to write about on itself. This post records the decisions that shaped the theme, so that when I want to add something later, I remember why I left it out in the first place.&lt;/p&gt;
&lt;h2 id="why-build-your-own"&gt;Why build your own&lt;/h2&gt;&lt;p&gt;Using a ready-made theme is like renting a furnished flat: you can move in today, but moving a shelf means asking the landlord. Every time Hugo changed something, I had to read someone else&amp;rsquo;s code to find out whether the theme still worked.&lt;/p&gt;
&lt;p&gt;Writing your own is slower at first, but afterwards everything has an owner. When a page renders wrong, I know which file to open. When a new Hugo release lands, the list of things that might break is short enough to read in one evening.&lt;/p&gt;
&lt;p&gt;There is one more reason: writing a theme makes you actually learn Hugo. Lookup order, page bundles, render hooks, how multilingual sites fit together; you have to touch each of them at least once.&lt;/p&gt;
&lt;h2 id="keep-it-small"&gt;Keep it small&lt;/h2&gt;&lt;p&gt;The rule of thumb: everything added must answer &amp;ldquo;what does the reader get?&amp;rdquo;. If the answer is &amp;ldquo;it looks a bit fancier&amp;rdquo;, the answer is usually no.&lt;/p&gt;
&lt;h3 id="no-build-step"&gt;No build step&lt;/h3&gt;&lt;p&gt;No Node, no bundler, no PostCSS. The CSS is a handful of plain files that Hugo joins, minifies and fingerprints. The JavaScript is small ES modules, one job each: the theme toggle, the copy button on code blocks, the table of contents that tracks your scroll. All of it together is under ten kilobytes before compression.&lt;/p&gt;
&lt;h3 id="data-not-params"&gt;Data, not params&lt;/h3&gt;&lt;p&gt;The home page is a portfolio, but the personal details are not in &lt;code&gt;hugo.yaml&lt;/code&gt;. The bio and links live in &lt;code&gt;data/profile.yaml&lt;/code&gt;, the featured projects in &lt;code&gt;data/projects.yaml&lt;/code&gt;. The config file is left with the switches that turn features on and off, and it reads at a glance.&lt;/p&gt;
&lt;h3 id="no-shortcodes-of-its-own"&gt;No shortcodes of its own&lt;/h3&gt;&lt;p&gt;The theme ships no shortcodes. A shortcode is Hugo-only syntax; once it is in a post, the post is tied to the theme. Whatever Markdown can express, such as captioned images or callout boxes, the theme handles with render hooks, so the content stays plain Markdown.&lt;/p&gt;
&lt;h2 id="dark-by-default"&gt;Dark by default&lt;/h2&gt;&lt;p&gt;I mostly write and read at night, so the dark look is the default, not an afterthought. The moon and sun button in the top corner switches to light, and the choice is remembered for next time.&lt;/p&gt;
&lt;h3 id="no-white-flash"&gt;No white flash&lt;/h3&gt;&lt;p&gt;The hard part of a dark theme is the moment before the CSS applies: the page flashes white, then goes dark. The cure is a tiny script that runs right in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, before the browser paints anything:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;theme&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;light&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;data-theme&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;light&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Because dark is the default, the script only has work to do when the reader has picked light. With JavaScript off, the page is still dark and still readable.&lt;/p&gt;
&lt;h3 id="colours-are-tokens"&gt;Colours are tokens&lt;/h3&gt;&lt;p&gt;Every colour is a CSS variable in a single file: dark values on &lt;code&gt;:root&lt;/code&gt;, light values on &lt;code&gt;:root[data-theme=&amp;quot;light&amp;quot;]&lt;/code&gt;. To change the accent colour in both modes, a site overrides a few variables and never touches the theme.&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;When picking colours for a dark background, avoid pure white for text. A warm, moderately bright grey is far easier on the eyes over a long read.&lt;/p&gt;
&lt;/blockquote&gt;&lt;h2 id="vietnamese-typography"&gt;Vietnamese typography&lt;/h2&gt;&lt;p&gt;The theme puts Vietnamese first, so the text got the most care.&lt;/p&gt;
&lt;h3 id="fonts-with-every-diacritic"&gt;Fonts with every diacritic&lt;/h3&gt;&lt;p&gt;The font stack starts with Inter and Be Vietnam Pro, then falls back to system fonts. Both cover the full Vietnamese alphabet; when neither is installed, modern system fonts render it well too. What you want to avoid is a font missing a few glyphs like &amp;ldquo;ữ&amp;rdquo; or &amp;ldquo;ặ&amp;rdquo;, leaving a single word set in two typefaces.&lt;/p&gt;
&lt;h3 id="line-height"&gt;Line height&lt;/h3&gt;&lt;p&gt;Vietnamese stacks diacritics above and below the letters. A body line height of 1.7 keeps one line&amp;rsquo;s marks from touching the next. Headings use tighter spacing, since the type is larger and the lines are few.&lt;/p&gt;
&lt;h3 id="anchors-and-dates"&gt;Anchors and dates&lt;/h3&gt;&lt;p&gt;Heading IDs come out as ASCII, so on the Vietnamese page the section &amp;ldquo;Chữ tiếng Việt&amp;rdquo; is &lt;code&gt;#chu-tieng-viet&lt;/code&gt;: short and easy to share. The letter &amp;ldquo;đ&amp;rdquo; is dropped rather than turned into &amp;ldquo;d&amp;rdquo;, so the Vietnamese headings that contain it get a hand-written ID, as in &lt;code&gt;## Nền tối là mặc định {#nen-toi-la-mac-dinh}&lt;/code&gt;. Dates follow each language&amp;rsquo;s format, so a Vietnamese post shows the date the Vietnamese way rather than &amp;ldquo;February 14, 2026&amp;rdquo;.&lt;/p&gt;
&lt;h2 id="whats-left"&gt;What&amp;rsquo;s left&lt;/h2&gt;&lt;p&gt;There is plenty still to do: the archive page, search, a second language. But the core is solid and, more importantly, I understand every line of it. The rest can wait for later posts.&lt;/p&gt;</description></item><item><title>Planning the new year</title><link>https://tiennm99.github.io/nocturne/2026/01/10/ke-hoach-dau-nam/</link><pubDate>Sat, 10 Jan 2026 08:00:00 +0700</pubDate><guid>https://tiennm99.github.io/nocturne/2026/01/10/ke-hoach-dau-nam/</guid><description>&lt;p&gt;At the start of each year I write down three things I want done by the end of June. Never more, because a long list never gets finished. This year one of the three is the Hugo theme I mentioned in &lt;a href="https://tiennm99.github.io/nocturne/2025/08/15/ghi-chu-hugo/"&gt;my notes from August&lt;/a&gt;: &lt;code&gt;nocturne&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="why-write-my-own"&gt;Why write my own&lt;/h2&gt;&lt;p&gt;The theme I use works, but it is heavy. It has a slider, animations, and a whole folder of JavaScript I have never opened. Writing my own is the only way to know why each line is there.&lt;/p&gt;
&lt;h2 id="goals"&gt;Goals&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;No build step for CSS or JS: just Hugo and the ES modules browsers already understand.&lt;/li&gt;
&lt;li&gt;Vietnamese first. Other languages are a bonus, not a requirement.&lt;/li&gt;
&lt;li&gt;The home page is a portfolio; the posts are everything else.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="how-ill-know"&gt;How I&amp;rsquo;ll know&lt;/h2&gt;&lt;p&gt;A goal you cannot check is only a wish, so each one gets a simple test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; The site runs with &lt;code&gt;hugo server&lt;/code&gt; and no &lt;code&gt;npm install&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; A long post reads comfortably on a phone, even with JavaScript off.&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; One post in Vietnamese plus an English version, and switching between them never loses your place.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="not-doing"&gt;Not doing&lt;/h2&gt;&lt;p&gt;This list matters as much as the one above: no self-hosted comments, no icon library, no CSS framework. When something is needed, write exactly that part.&lt;/p&gt;
&lt;p&gt;More once the theme has taken shape.&lt;/p&gt;</description></item><item><title>Notes on Hugo and static sites</title><link>https://tiennm99.github.io/nocturne/2025/08/15/ghi-chu-hugo/</link><pubDate>Fri, 15 Aug 2025 09:00:00 +0700</pubDate><guid>https://tiennm99.github.io/nocturne/2025/08/15/ghi-chu-hugo/</guid><description>&lt;p&gt;Hugo is a static site generator written in Go. Coming back to it after a long break, I found a fair amount had changed. These are personal notes, not a tutorial: the things I want to remember before starting on something bigger.&lt;/p&gt;
&lt;h2 id="the-new-layout-convention"&gt;The new layout convention&lt;/h2&gt;&lt;p&gt;Since 0.146, the special folders inside &lt;code&gt;layouts/&lt;/code&gt; start with an underscore: &lt;code&gt;_partials&lt;/code&gt;, &lt;code&gt;_markup&lt;/code&gt;, &lt;code&gt;_shortcodes&lt;/code&gt;. The underscore keeps them apart from section names, so a section called &lt;code&gt;partials&lt;/code&gt; can no longer be mistaken for the folder of partials.&lt;/p&gt;
&lt;h3 id="the-_partials-folder"&gt;The &lt;code&gt;_partials&lt;/code&gt; folder&lt;/h3&gt;&lt;p&gt;Reusable template pieces live here: the header, the footer, a post card. A section is a kind of content; a partial is just a piece of the page.&lt;/p&gt;
&lt;h3 id="the-_markup-folder"&gt;The &lt;code&gt;_markup&lt;/code&gt; folder&lt;/h3&gt;&lt;p&gt;Render hooks for Markdown: headings, links, images, code blocks, tables, blockquotes. Hugo finds them on its own while rendering content; nothing needs registering.&lt;/p&gt;
&lt;h3 id="the-_shortcodes-folder"&gt;The &lt;code&gt;_shortcodes&lt;/code&gt; folder&lt;/h3&gt;&lt;p&gt;Exactly what it says. A shortcode placed here in your site overrides the theme&amp;rsquo;s shortcode of the same name.&lt;/p&gt;
&lt;h2 id="the-asset-pipeline"&gt;The asset pipeline&lt;/h2&gt;&lt;p&gt;Hugo needs no external build tool. &lt;code&gt;resources.Get&lt;/code&gt; picks up a file from &lt;code&gt;assets/&lt;/code&gt;, &lt;code&gt;resources.Concat&lt;/code&gt; joins files, &lt;code&gt;minify&lt;/code&gt; compresses them and &lt;code&gt;fingerprint&lt;/code&gt; puts a hash in the file name. For a small to medium site, that is the whole pipeline.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;markup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;goldmark&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;autoHeadingIDType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;github-ascii&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This one setting solves a big problem for anyone writing in Vietnamese: heading IDs come out as plain ASCII, stable and URL-safe. &amp;ldquo;Thư mục&amp;rdquo; becomes &lt;code&gt;#thu-muc&lt;/code&gt; instead of a long run of percent-encoded bytes. Only &amp;ldquo;đ&amp;rdquo; is dropped rather than turned into &amp;ldquo;d&amp;rdquo;; when it matters, write the ID by hand right after the heading text, as the Vietnamese version of this post does with &lt;code&gt;{#di-tiep}&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="render-hooks"&gt;Render hooks&lt;/h2&gt;&lt;p&gt;Render hooks let you step into Markdown rendering without writing a Goldmark extension. A small template in &lt;code&gt;_markup/&lt;/code&gt; is enough.&lt;/p&gt;
&lt;p&gt;A few things I reach for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;#&lt;/code&gt; anchor link next to each heading;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rel=&amp;quot;noopener&amp;quot;&lt;/code&gt; on outbound links;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;srcset&lt;/code&gt;, dimensions and &lt;code&gt;loading=&amp;quot;lazy&amp;quot;&lt;/code&gt; on images, so the page does not jump while it loads.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="things-worth-keeping"&gt;Things worth keeping&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Plain Markdown is a long-term asset. Any generator can read it.&lt;/li&gt;
&lt;li&gt;Hugo is rarely what makes a build slow. When it is slow, the culprit is usually image processing or an over-eager resource pipeline.&lt;/li&gt;
&lt;li&gt;A light theme makes a light site. Every byte of CSS and JS travels over the network to the reader.&lt;/li&gt;
&lt;li&gt;Writing your own theme is how you get to understand every line. Ready-made themes are convenient, but they bring a lot you never needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="whats-next"&gt;What&amp;rsquo;s next&lt;/h2&gt;&lt;p&gt;The project for the coming months: a Hugo theme of my own, small, with no build step and Vietnamese first. It is called &lt;code&gt;nocturne&lt;/code&gt;. I will write it and keep notes along the way in this series.&lt;/p&gt;
&lt;p&gt;The next entry will probably be the actual plan, then the CSS and how to do dark mode without a white flash on first load.&lt;/p&gt;</description></item></channel></rss>