<?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 Aamnah - Frontend Web Developer</title>
    <link>https://aamnah.com/notes/hugo/</link>
    <description>Recent content in Hugo on Aamnah - Frontend Web Developer</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 19 Oct 2026 00:10:00 +0300</lastBuildDate>
    <atom:link href="https://aamnah.com/notes/hugo/rss.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Add author profiles to blog posts on Hugo websites</title>
      <link>https://aamnah.com/notes/hugo/hugo-add-author-profiles-to-blog-posts/</link>
      <pubDate>Thu, 27 Jun 2024 22:31:33 +0300</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-add-author-profiles-to-blog-posts/</guid>
      <description>How to show Author details with every Hugo blog post</description>
    </item>
    <item>
      <title>Load content from a github repo for a hugo website as a module</title>
      <link>https://aamnah.com/notes/hugo/load-content-from-a-github-repo-for-a-hugo-website-as-a-module/</link>
      <pubDate>Tue, 25 Jun 2024 21:03:21 +0300</pubDate>
      <guid>https://aamnah.com/notes/hugo/load-content-from-a-github-repo-for-a-hugo-website-as-a-module/</guid>
      <description>&lt;p&gt;NOTES:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In 2024 a &lt;a href=&#34;https://github.com/gohugoio/hugo/issues/11458&#34;&gt;bug&lt;/a&gt; stopped &lt;code&gt;hugo mod init&lt;/code&gt; (and the other &lt;code&gt;hugo mod&lt;/code&gt; commands) when a &lt;code&gt;module.toml&lt;/code&gt; already existed. Fixed in Hugo v0.134.3 (September 2024).&lt;/li&gt;&#xA;&lt;li&gt;Install Hugo from the &lt;code&gt;apt&lt;/code&gt; package or the official release binary instead of the &lt;code&gt;snap&lt;/code&gt;. The snap is strictly confined, so &lt;code&gt;hugo mod&lt;/code&gt; can&amp;rsquo;t reach your SSH keys and you get weird permission errors with SSH auth&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://gohugo.io/commands/hugo_mod/&#34;&gt;https://gohugo.io/commands/hugo_mod/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In order to load modules, your site needs to be a module itself.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hugo assets directory</title>
      <link>https://aamnah.com/notes/hugo/hugo-assets-directory/</link>
      <pubDate>Sat, 08 Jun 2024 13:43:17 +0300</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-assets-directory/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;If you want any file to be processed by &lt;a href=&#34;https://gohugo.io/hugo-pipes/introduction/&#34;&gt;Hugo Pipes&lt;/a&gt;, for example compiling Sass stylesheets or converting TypeScript files to JavaScript, it needs to be in the &lt;em&gt;assets&lt;/em&gt; directory, which by default is &lt;code&gt;assets/&lt;/code&gt;, but can be configured in &lt;code&gt;config.toml&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Only the files in assetDir &lt;strong&gt;that are processed&lt;/strong&gt; will be included in the final build&lt;/li&gt;&#xA;&lt;li&gt;Unlike &lt;code&gt;staticDir&lt;/code&gt; which can take an array of values for multiple static directories, there can only be one &lt;code&gt;assetDir&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-toml&#34; data-lang=&#34;toml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;staticDir&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;assets&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;static&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;assetDir&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;assets/&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you are creating or using a custom theme, the files in the themes asset directory &lt;code&gt;themes/foo/assets&lt;/code&gt; will NOT be processed by Hugo pipes by default.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;You can however &lt;em&gt;mount&lt;/em&gt; multiple asset directories. Mounting a new directory means the default directory is ignored, so be sure to explicitly add it again if you want the default directory to work&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Targeting a template for Hugo website content pages</title>
      <link>https://aamnah.com/notes/hugo/targeting-a-template-for-hugo-website-content-pages/</link>
      <pubDate>Wed, 05 Jun 2024 17:34:45 +0300</pubDate>
      <guid>https://aamnah.com/notes/hugo/targeting-a-template-for-hugo-website-content-pages/</guid>
      <description>&lt;p&gt;To use a specific layout for your content pages and override the default template lookup order, you specify &lt;code&gt;layout&lt;/code&gt;, &lt;code&gt;kind&lt;/code&gt;, or both in the front matter. Here are a bunch of examples:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;layouts/notes/baseof.html - serves as the templates for the notes SECTION&#xA;layouts/page/notes.html - serves as the template for the notes PAGE&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Here&amp;rsquo;s an example directory structure for your layouts:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;themes/amnastic/layouts/notes/     &#xA;├── baseof.html&#xA;├── landing.html                &#xA;├── section.html               &#xA;└── single.html                  &#xA;                                                               &#xA;0 directories, 4 files &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&#xA;&lt;li&gt;If you just define &lt;code&gt;layout:notes&lt;/code&gt; in your content page, it will render the PAGE layout at &lt;code&gt;layouts/pages/notes.html&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# use the template at layouts/pages/notes.html&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;layout&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;notes &lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;If you just define &lt;code&gt;type:notes&lt;/code&gt;, it will render the layout template at &lt;code&gt;layouts/notes/baseof.html&lt;/code&gt; or &lt;code&gt;layouts/notes/single.html&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# use the template at layouts/notes/baseof.html or layouts/notes/single.html&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;type&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;notes &lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;If you define a &lt;code&gt;type&lt;/code&gt; and a &lt;code&gt;layout&lt;/code&gt; both, it will look under the &lt;code&gt;type&lt;/code&gt; directory for that specific &lt;code&gt;layout&lt;/code&gt;, like the following:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;type&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;notes&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# look under layouts/notes/&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;layout&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;landing&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c&#34;&gt;# for a layout called landing, i.e. layouts/notes/landing.html&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;defining-layouts-for-subsections&#34;&gt;Defining layouts for subsections&lt;/h3&gt;&#xA;&lt;p&gt;I have one &lt;em&gt;notes&lt;/em&gt; (usually called &lt;em&gt;posts&lt;/em&gt;) with folders serving as post &lt;em&gt;categories&lt;/em&gt;. From Hugo&amp;rsquo;s perspective, &lt;code&gt;notes/&lt;/code&gt; is a section and all the individual directories inside &lt;code&gt;notes/&lt;/code&gt;, for example &lt;code&gt;notes/algorithms/&lt;/code&gt;, &lt;code&gt;notes/android&lt;/code&gt; etc. are all sub-sections. In my site, i have about 50+ of these subsections.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Customizing Chroma in Hugo and Light/Dark syntax highlighting themes</title>
      <link>https://aamnah.com/notes/hugo/hugo-custom-chroma-syntax-highlighting/</link>
      <pubDate>Wed, 30 Nov 2022 15:45:44 +0500</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-custom-chroma-syntax-highlighting/</guid>
      <description>&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Disable inline styles for syntax highlighting&lt;/li&gt;&#xA;&lt;li&gt;Generate stylesheets&lt;/li&gt;&#xA;&lt;li&gt;Use an inline &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag in your template file, and load Hugo partials inside a media query (or load stylesheet based on a data attribute value)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Hugo uses &lt;a href=&#34;https://github.com/alecthomas/chroma&#34;&gt;Chroma&lt;/a&gt; by default. You can use &lt;a href=&#34;https://prismjs.com/index.html&#34;&gt;Prism&lt;/a&gt; instead if you want.&lt;/p&gt;&#xA;&lt;p&gt;Chroma renders the highlighted syntax at build time&lt;/p&gt;&#xA;&lt;p&gt;PrismJS gives you a lot of flexibility in terms of plugins, themes and portability.&lt;/p&gt;&#xA;&lt;p&gt;PrismJS renders client side whereas Chroma probably renders at build time. Chroma is probably really good for site performance.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using PrismJS for Hugo sites</title>
      <link>https://aamnah.com/notes/hugo/hugo-chroma-prismjs/</link>
      <pubDate>Wed, 30 Nov 2022 13:08:36 +0500</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-chroma-prismjs/</guid>
      <description>&lt;p&gt;NOTE: I have stopped using Prism for syntax highlighting and use Hugo&amp;rsquo;s built-in Chroma highlighting instead. The huge advantage Chroma has over Prism is site performance. Chroma renders the highlighted syntax at build time whereas Prism renders client side. Prism is also going to download ~50kb on site load. The file size is actually bigger if you are using many plugins and supporting many languages.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Hugo uses &lt;a href=&#34;https://github.com/alecthomas/chroma&#34;&gt;Chroma&lt;/a&gt; by default. You can use &lt;a href=&#34;https://prismjs.com/index.html&#34;&gt;Prism&lt;/a&gt; instead if you want. PrismJS gives you a lot of flexibility in terms of plugins, themes and portability.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hugo Modules</title>
      <link>https://aamnah.com/notes/hugo/hugo-modules-intro/</link>
      <pubDate>Wed, 16 Nov 2022 00:00:01 +0500</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-modules-intro/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;Hugo modules are &lt;strong&gt;read-only&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can mount any folder from any public remote or local location, including GitHub repos and local folders on your system&lt;/li&gt;&#xA;&lt;li&gt;What sort of a module it is determined by the &lt;code&gt;target&lt;/code&gt; path where it is mounted&lt;/li&gt;&#xA;&lt;li&gt;What can be a module? One or more of the 7 component types defined in Hugo: &lt;code&gt;static&lt;/code&gt;, &lt;code&gt;content&lt;/code&gt;, &lt;code&gt;layouts&lt;/code&gt;, &lt;code&gt;data&lt;/code&gt;, &lt;code&gt;assets&lt;/code&gt;, &lt;code&gt;i18n&lt;/code&gt;, and &lt;code&gt;archetypes&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;getting-started&#34;&gt;Getting started&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should be using versions of Go and Hugo that support modules&lt;/li&gt;&#xA;&lt;li&gt;Your Hugo site itself needs to be initialized as a module in order for this to work&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Import&lt;/em&gt; a module by mentioning its &lt;code&gt;path&lt;/code&gt;. By default all modules are assumed to be themes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Mount&lt;/em&gt; a module (or a folder) in a particular location by mention &lt;code&gt;source&lt;/code&gt; and &lt;code&gt;target&lt;/code&gt; locations&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hugo serve&lt;/code&gt; automatically fetches the modules if needed&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hugo mod vendor&lt;/code&gt; shows the mounted modules in a directory called &lt;code&gt;_vendor&lt;/code&gt; inside your project root instead of loading them in &lt;code&gt;cacheDir&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;hugo mod init github.com/aamnah/aamnah.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# this will create a file called: go.mod&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;hugo mod vendor&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;what-can-i-mount-as-a-module&#34;&gt;What can i mount as a module?&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Any form of assets. For example: Icon libraries like &lt;a href=&#34;https://heroicons.com/&#34;&gt;Heroicons&lt;/a&gt; or &lt;a href=&#34;https://remixicon.com/&#34;&gt;Remix Icons&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Any form of shared content. For example: documentation for a project&lt;/li&gt;&#xA;&lt;li&gt;Any theme or UI framework&lt;/li&gt;&#xA;&lt;li&gt;Branding assets&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;archetypes&lt;/code&gt; for creating new content based on templates. For example: archetypes for creating blog posts with pre-filled front matter&lt;/li&gt;&#xA;&lt;li&gt;Anything that fits the 7 content types of hugo.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;links&#34;&gt;Links&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.hugofordevelopers.com/articles/master-hugo-modules-managing-themes-as-modules/&#34;&gt;Master Hugo Modules: Managing Themes As Modules&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.hugofordevelopers.com/articles/master-hugo-modules-handle-content-or-assets-as-modules/&#34;&gt;Master Hugo Modules: Handle Content Or Assets As Modules&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Hugo Config Directories</title>
      <link>https://aamnah.com/notes/hugo/hugo-config-directory-partials/</link>
      <pubDate>Tue, 15 Nov 2022 23:21:18 +0500</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-config-directory-partials/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;The file is named after a configuration root &lt;em&gt;object&lt;/em&gt;.&#xA;Root objects are the ones that have a single square bracket. For example: &lt;code&gt;[module]&lt;/code&gt;, &lt;code&gt;[menu]&lt;/code&gt;, &lt;code&gt;[Params]&lt;/code&gt; etc. These you can split into their own files, named after the object. For example: &lt;code&gt;module.toml&lt;/code&gt;, &lt;code&gt;menu.toml&lt;/code&gt; or &lt;code&gt;menus.toml&lt;/code&gt;, &lt;code&gt;params.toml&lt;/code&gt; etc.&lt;/li&gt;&#xA;&lt;li&gt;Since the files are named after the root object, you&amp;rsquo;d skip mentioning the root object itself, i.e. the config will be top-level.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;code-samples&#34;&gt;Code samples&lt;/h3&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s a chunk of configuration from the &lt;code&gt;config.toml&lt;/code&gt; file&lt;/p&gt;</description>
    </item>
    <item>
      <title>Auto compiling Sass and SCSS in Hugo</title>
      <link>https://aamnah.com/notes/hugo/hugo-auto-compile-sass/</link>
      <pubDate>Fri, 28 Oct 2022 00:00:00 +0500</pubDate>
      <guid>https://aamnah.com/notes/hugo/hugo-auto-compile-sass/</guid>
      <description>&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;scss&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;resources&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Get&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;scss/main.scss&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;css&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;scss&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;resources&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;toCSS&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;link&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;rel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;stylesheet&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;href&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{{ $css.RelPermalink }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;Your Sass files need to be in the &lt;code&gt;assets/&lt;/code&gt; folder for you to be able to pipe commands with &lt;code&gt;|&lt;/code&gt;. By default the &lt;a href=&#34;https://gohugo.io/hugo-pipes/introduction/#asset-directory&#34;&gt;assetDir&lt;/a&gt; is &lt;code&gt;assets/&lt;/code&gt; in the project root. By default, you can only have one &lt;code&gt;assetDir&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can mount your theme&amp;rsquo;s assets directory &lt;code&gt;themes/BLAH/assets/&lt;/code&gt; (i.e. multiple &lt;code&gt;assetDir&lt;/code&gt;s) as a module with a custom mount configuration. Read: &lt;a href=&#34;./hugo-assets-directory&#34;&gt;Hugo assets directory&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:=&lt;/code&gt; is also known as the walrus operator. It means definition and assignment&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;resources.Get&lt;/code&gt;locates the filename given in Hugo’s assets filesystem and creates a &lt;code&gt;Resource&lt;/code&gt; object that can be used for further transformations.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;RelPermalink&lt;/code&gt; would get the relative permalink. Meaning &lt;code&gt;/scss/main.css&lt;/code&gt; instead of &lt;code&gt;http://mysite.com/scss/main.css&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;scss&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;resources&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Get&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;scss/main.scss&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;css&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;scss&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;ToCSS&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;link&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;rel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;stylesheet&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;href&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{{ $css.RelPermalink }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;err&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;style&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;resources&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Get&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;scss/main.scss&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;resources&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;ToCSS&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;link&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;rel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;stylesheet&amp;#34;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;href&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{{ $style.RelPermalink }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also specify options like you normally would if you ran &lt;code&gt;dart-sass&lt;/code&gt; or &lt;code&gt;sass&lt;/code&gt; CLI&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
