Hugo

Setup

  • Language :

    • Go.

  • Templates :

    • Go.

  • By :

    • Hugo.

  • License :

    • Apache-2.0.

  • Hugo .

  • Hugo .

  • Go.

  • HTML

  • MD to HTML based on the structure of the file system.

Installation
  • Releases .

  • (2025-10-11)

    • I got the Windows AMD 0.151.0, classic.

      • I got this error when running hugo server  with the anake  theme installed.

      • Error: error building site: TOCSS: failed to transform "/ananke/css/main.css" (text/css). Check your Hugo installation; you need the extended version to build SCSS/SASS with transpiler set to 'libsass'.: this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information

      • I guess eu deveria usar a extended, idk.

    • I got the Windows AMD 0.151.0, extended.

  • If you want to check the version:

hugo version
  • Help:

hugo help
# or for a subcommand:
hugo server --help
New site
  • hugo new site .

Config

Configuration
  • For projects with minimal configuration or projects that do not need to behave differently in different environments, a single configuration file named hugo.toml  in the root of the project is sufficient.

└── hugo.toml         <-- site configuration
  • Depending on requirements, you may wish to organize your site configuration into subdirectories:

β”œβ”€β”€ config/           <-- site configuration
β”‚   └── _default/
β”‚       └── hugo.toml
Default Configurations
  • hugo config --printZero >> config/_default/hugo.toml

TOML
  • Open tables :

    [server]
    
  • Close tables :

    • TOML tables do not require or allow explicit closing syntax.

    • A table implicitly closes when:

      • Another table header ( [something]  or [something.sub] ) appears, or

      • The file ends.

Privacy
  • THE DEFAULT IS NO PRIVACY HAHAHHA.

  • All the tracking is enabled by default, and you can only disable or even know these things are enabled if you search through the whole documentation for it.

  • If this is not a crime, it should be a crime.

    • I asked ChatGPT about this and I got mad, so anyway....

  • Disqus .

  • Google Analytics .

  • Instagram .

  • Vimeo .

  • Twitter .

  • Youtube .

    • privacyEnhanced

      • Whether to block YouTube from storing information about visitors on your website unless the user plays the embedded video.

      • Default is false .

  • Configurations used by me:

    • I only enabled youtube, with "privacy enhanced".

[privacy]
[privacy.disqus]
disable = true

[privacy.googleanalytics]
disable = true
respectdonottrack = true

[privacy.instagram]
disable = true
simple = true

[privacy.twitter]
disable = false
enablednt = false
simple = false

[privacy.vimeo]
disable = true
enablednt = true
simple = false

[privacy.x]
disable = true
enablednt = true
simple = true

[privacy.youtube]
disable = false
privacyenhanced = true

Renderer

Translation

i18n
  • The i18n  directory contains translation tables for multilingual sites.

  • details .

Content

Archetypes
  • The archetypes  directory contains templates for new content.

  • Only used on creation. If an archetype is modified after a file is created, the file doesn't care.

  • Lookup Order :

    • The name of the archetype file defines where the template will be applied.

    • An archetype for a specific content type takes precedence over the default archetype.

      • archetypes/dir1.md  will be the template for content/dir1  files.

    • For:

      hugo new content posts/my-first-post.md
      
    • The archetype lookup order is:

      1. archetypes/posts.md

      2. archetypes/default.md

      3. themes/my-theme/archetypes/posts.md

      4. themes/my-theme/archetypes/default.md

    • If none of these exists, Hugo uses a built-in default archetype.

  • Explicit Archetype :

    • Use the --kind  command line flag to specify an archetype when creating content.

    • Ex :

      • To create an article using the articles  archetype:

      hugo new content articles/something.md
      
      • To create an article using the tutorials  archetype:

      hugo new content --kind tutorials articles/something.md
      
Content
  • The content  directory contains the markup files (typically Markdown) and page resources that comprise the content of your site.

hugo new content content/posts/my-first-post.md
  • Draft :

    • Rascunho.

  • Future :

  • Expired :

  • By default, Hugo will not publish content when:

    • The draft  value is true

    • The date  is in the future

    • The publishDate  is in the future

    • The expiryDate  is in the past

hugo --buildDrafts    # or -D
hugo --buildExpired   # or -E
hugo --buildFuture    # or -F
  • Hugo publishes descendants of draft, future, and expired node  pages. To prevent publication of these descendants, use the cascade  front matter field to cascade build options  to the descendant pages.

URL
  • Slug, URL, Aliases, Ugly URLs .

  • url

    • The url is the entire URL path, defined by the file path and optionally overridden by a url value in front matter.

  • ugly url :

    • Is a URL that includes a file extension.

    • CAREFUL :

      • Enabling Ugly URLs will make the URLs go from /docs/vulkan/vulkan-fast-test/  to /docs/vulkan/vulkan-fast-test.html .

      • Doing so will affect all image

  • section

    • A default content type is determined by the section in which a content item is stored.

    • section is determined by the location within the project’s content  directory.

    • section cannot be specified or overridden in front matter.

  • slug

    • Is the last segment of the URL path, defined by the file name and optionally overridden by a slug value in front matter.

  • path

    • A content’s path is determined by the section’s path to the file.

    • The file path:

      • Is based on the path to the content’s location AND

      • Does not include the slug

Content Organization
  • Without any additional configuration, the following will automatically work:

.
└── content
    β””── about
    |   └── index.md  // <- https://example.org/about/
    β”œβ”€β”€ posts
    |   β”œβ”€β”€ firstpost.md   // <- https://example.org/posts/firstpost/
    |   β”œβ”€β”€ happy
    |   |   └── ness.md  // <- https://example.org/posts/happy/ness/
    |   └── secondpost.md  // <- https://example.org/posts/secondpost/
    β””── quote
        β”œβ”€β”€ first.md       // <- https://example.org/quote/first/
        β””── second.md      // <- https://example.org/quote/second/
Section
  • A section  is a top-level content directory or any content directory containing anΒ  _index.md Β file.

content/
β”œβ”€β”€ articles/             <-- section (top-level directory)
β”‚   β”œβ”€β”€ 2022/
β”‚   β”‚   β”œβ”€β”€ article-1/
β”‚   β”‚   β”‚   β”œβ”€β”€ cover.jpg
β”‚   β”‚   β”‚   └── index.md
β”‚   β”‚   └── article-2.md
β”‚   └── 2023/
β”‚       β”œβ”€β”€ article-3.md
β”‚       └── article-4.md
β”œβ”€β”€ products/             <-- section (top-level directory)
β”‚   β”œβ”€β”€ product-1/        <-- section (has _index.md file)
β”‚   β”‚   β”œβ”€β”€ benefits/     <-- section (has _index.md file)
β”‚   β”‚   β”‚   β”œβ”€β”€ _index.md
β”‚   β”‚   β”‚   β”œβ”€β”€ benefit-1.md
β”‚   β”‚   β”‚   └── benefit-2.md
β”‚   β”‚   β”œβ”€β”€ features/     <-- section (has _index.md file)
β”‚   β”‚   β”‚   β”œβ”€β”€ _index.md
β”‚   β”‚   β”‚   β”œβ”€β”€ feature-1.md
β”‚   β”‚   β”‚   └── feature-2.md
β”‚   β”‚   └── _index.md
β”‚   └── product-2/        <-- section (has _index.md file)
β”‚       β”œβ”€β”€ benefits/     <-- section (has _index.md file)
β”‚       β”‚   β”œβ”€β”€ _index.md
β”‚       β”‚   β”œβ”€β”€ benefit-1.md
β”‚       β”‚   └── benefit-2.md
β”‚       β”œβ”€β”€ features/     <-- section (has _index.md file)
β”‚       β”‚   β”œβ”€β”€ _index.md
β”‚       β”‚   β”œβ”€β”€ feature-1.md
β”‚       β”‚   └── feature-2.md
β”‚       └── _index.md
β”œβ”€β”€ _index.md
└── about.md
Static
  • When Hugo compiles the site, it takes everything from the static  folder and content  folder and puts in the content directory.

    • So for example, if you have an image static/pic.png , the following link will work, as the /pic.png  will be in the same folder as the note.

Images
Taxonomies
  • It's just a way to group content.

  • Hugo automatically generate pages based on taxonomy.

  • Tags :

    • In the frontmatter:

    tags = ["tag1", "tag2", "tag3"]
    
  • Categories :

    • In the frontmatter:

    categories = ["cat1"]
    
  • Custom frontmatter keys can be used, but in that case, Hugo will not automatically create the pages for you.

  • For the page be automatically generated in this case, you have to define the taxonomies in the config file:

[taxonomies]
    tag = "tags"
    category = "categories"
    mood = "moods"
assets
  • The assets  directory contains global resources typically passed through an asset pipeline.

  • This includes resources such as images, CSS, Sass, JavaScript, and TypeScript.

  • SeeΒ  details .

data
  • The data  directory contains data files (JSON, TOML, YAML, or XML) that augment content, configuration, localization, and navigation.

  • Hugo merges the data files to create a single data structure, accessible with the Data  method on a Site  object.

"Programming"

{{- $js := slice 
    (resources.Get "js/color-preference.js") 
    (resources.Get "js/off-canvas.js")
    (resources.Get "js/table-of-contents.js") 
    | resources.Concat "assets/js/docs.js" 
    | minify 
    | fingerprint
}}
  • resources.Get

    • This loads a single asset from the assets/  directory in your Hugo project.

    • So resources.Get "js/color-preference.js"  fetches that file as a Hugo Resource .

  • slice

    • The slice  function creates a list  of items.

    • Here, it creates a list of the three JS resources.

    • So after this step, you have a slice of three JS resources .

  • | resources.Concat "assets/js/docs.js"

    • The pipe ( | ) passes the slice to resources.Concat .

    • resources.Concat "assets/js/docs.js"   combines all the files  in the slice into a single file.

    • "assets/js/docs.js"  is the target name  for the concatenated file.

    • So now you have one JS file  combining the three original files.

  • | minify

    • This compresses the concatenated JS file to reduce its size.

    • Removes whitespace, comments, and sometimes shortens variable names.

    • Good for production, because it makes the site load faster.

  • | fingerprint

    • This adds a hash  to the filename, e.g., docs.3a7f9e.js .

    • Helps with cache busting : browsers will download a new version if the file changes.

  • {{- $js := ... }}

    • Finally, the entire processed resource is assigned to the variable $js .

    • You can then use it in your template, for example:

(( range $some_page := .Site.Sections ))
    <p>
        (( printf "%#v" $some_page.File.BaseFileName ))
    </p>
(( end ))
Go Templates
  • |

    • Pipe operator. Passes the value on the left as input to the function on the right.

  • ((-  / -))

    • Trim whitespace before or after the tag.

Variables
(( $var1 := "dog" ))
(( $var2 := "cat" ))
Conditionals
  • eq

    • Equal

  • lt

    • Less than

  • gt

    • Greater than

  • ge

    • Greater or equal to

(( if eq $var1 $var2 ))
    It is true
(( else ))
    It is false
(( end ))
(( if not (eq $var1 $var2) ))
    It is true
(( else ))
    It is false
(( end ))
(( if and (lt $var1 $var2) (lt $var1 $var3) ))
    It is true
(( else ))
    It is false
(( end ))

Functions / Methods

Functions
Range
(( range .Pages ))
    (( .Title )) <br>
(( end ))
  • When iterating over something, the variables accessed inside the loop are from the current iteration.

Methods
Site
  • Methods - Site .

  • Site.Home .

    (( .Site.Home.Permalink )) β†’ https://example.org/docs/ 
    (( .Site.Home.RelPermalink )) β†’ /docs/
    
  • Site.Pages .

    (( range .Site.Pages ))
      <h2><a HREF="(( .RelPermalink ))">(( .LinkTitle ))</a></h2>
    (( end ))
    
  • Site.Sections .

    // This structure
    content/
    β”œβ”€β”€ books/
    β”‚   β”œβ”€β”€ book-1.md
    β”‚   └── book-2.md
    β”œβ”€β”€ films/
    β”‚   β”œβ”€β”€ film-1.md
    β”‚   └── film-2.md
    └── _index.md
    
    // Templated like:
    (( range .Site.Sections ))
      <h2><a HREF="(( .RelPermalink ))">(( .LinkTitle ))</a></h2>
    (( end ))
    
    // Renders to:
    <h2><a HREF="/books/">Books</a></h2>
    <h2><a HREF="/films/">Films</a></h2>
    
  • Site.MainSections .

    // Toml
    mainSections = ['books', 'films']
    
    // GO
    (( .Site.MainSections )) β†’ [books films]
    
    • If mainSections  is not  defined in the site configuration, this method returns a slice with one elementβ€”the top-level section with the most pages.

Page
Pages

Layouts / Templating

Layouts
  • HTML Templates.

  • Any folder in layouts  that does not start with _  represents the root of a Page path . In Hugo v0.146.0 , this can be nested as deeply as needed, and _shortcodes  and _markup  folders can be placed at any level in the tree.

  • The layouts/shortcodes  folder is renamed to layouts/_shortcodes .

  • The layouts/partials  folder is renamed to layouts/_partials .

  • The _default  folder is removed.

    • Move all files in layouts/_default  up to the layouts/  root.

  • The above also means that there’s no top-level layouts/taxonomy  or layouts/section  folders anymore, unless it represents a Page path .

    • Move them up to layouts/  with one of the Page kinds   section , taxonomy  or term  as the base name, or place the layouts into the taxonomy Page path .

  • A template named taxonomy.html  used to be a candidate for both Page kind term  and taxonomy , now it’s only considered for taxonomy .

    • Create both taxonomy.html  and term.html  or create a more general layout, e.g. list.html .

  • For base templates (e.g., baseof.html ), in previous Hugo versions, you could prepend one identifier (layout, type, or kind) with a hyphen in front of the baseof keyword.

    • Move that identifier after the first β€œdot,” e.g., rename list-baseof.html  to baseof.list.html .

  • We have added a new all  β€œcatch-all” layout. This means that if you have, e.g., layouts/all.html  and that is the only template, that layout will be used for all HTML page rendering.

  • We have removed the concept of _internal  Hugo templates. 1

    • Replace constructs similar to {{ template "_internal/opengraph.html" . }}  with {{ partial "opengraph.html" . }} .

  • The identifiers that can be used in a template filename are one of the Page kinds  ( home , page , section , taxonomy , or term ), one of the standard layouts ( list , single , or all ), a custom layout (as defined in the layout  front matter field), a language (e.g., en ), an output format (e.g., html , rss ), and a suffix representing the media type. E.g., all.en.html  and home.rss.xml .

  • The above means that there’s no such thing as an index.html  template for the home page anymore.

    • Rename index.html  to home.html .

Types
  • Base :

    • A base  template serves as a foundational layout that other templates can build upon. It typically defines the common structural components of your HTML, such as the html , head , and body  elements. It also often includes recurring features like headers, footers, navigation, and script inclusions that appear across multiple pages of your site.

    • Hugo can apply a base  template to the following template types: home , page , section , taxonomy , term , single , list , and all . When Hugo parses any of these template types, it will apply a base  template only if the template being parsed meets these specific conditions:

    • If a template doesn’t meet all these criteria, Hugo executes it exactly as provided, without applying a base  template.

    • When Hugo applies a base  template, it replaces its block  actions with content from the corresponding define  actions found in the template to which the base template is applied.

    • For example, the base  template below calls the partial  function to include head , header , and footer  elements. The block  action acts as a placeholder, and its content will be replaced by a matching define  action from the template to which it is applied.

  • Home :

    • A home  template renders your site’s home page.

    • For example, Hugo applies a base  template to the home  template, then renders the page content and a list of the site’s regular pages.

  • Page :

    • A page  template renders a regular page.

    • For example, Hugo applies a base  template to the page  template, then renders the page title and page content.

  • Section :

    • A section  template renders a list of pages within a section .

    • For example, Hugo applies a base  template to the section  template, then renders the page title, page content, and a list of pages in the current section.

  • Taxonomy :

    • A taxonomy  template renders a list of terms in a taxonomy .

    • For example, Hugo applies a base  template to the taxonomy  template, then renders the page title, page content, and a list of terms  in the current taxonomy.

    • Within a taxonomy  template, the Data  object provides these taxonomy-specific methods:

    • The Terms  method returns a taxonomy object , allowing you to call any of its methods including Alphabetical  and ByCount . For example, use the ByCount  method to render a list of terms sorted by the number of pages associated with each term:

  • Term :

    • A term  template renders a list of pages associated with a term .

    • For example, Hugo applies a base  template to the term  template, then renders the page title, page content, and a list of pages associated with the current term.

    • Within a term  template, the Data  object provides these term-specific methods:

  • Single :

    • A single  template is a fallback for a page  template. If a page  template does not exist, Hugo will look for a single  template instead.

    • For example, Hugo applies a base  template to the single  template, then renders the page title and page content.

  • List :

    • A list  template is a fallback for home , section , taxonomy , and term  templates. If one of these template types does not exist, Hugo will look for a list  template instead.

    • For example, Hugo applies a base  template to the list  template, then renders the page title, page content, and a list of pages.

    • _index.md .

      • It allows you to add front matter and content to home , section , taxonomy , and term  pages.

      • Access the content and metadata within an _index.md  file by invoking the GetPage  method on a Site  or Page  object.

  • All :

    • An all  template is a fallback for home , page , section , taxonomy , term , single , and list  templates. If one of these template types does not exist, Hugo will look for an all  template instead.

    • For example, Hugo applies a base  template to the all  template, then conditionally renders a page based on its page kind.

  • Partial :

    • A partial  template is typically used to render a component of your site, though you may also create partial  templates that return values.

    • Partials vs Shortcodes :

      • You can Partials in Templates.

      • You can Shortcodes in files.

    (( partial "header" . ))
    
    • The .  represents the scope of what you want to access.

    • "header"  is the name of the partial template, located as layouts/partial/header.html .

Lookup Order

|Identifier|Description|
|---|---|
|Layout custom|The custom layout  set in front matter.|
| Page kinds |One of home , section , taxonomy , term , page .|
|Layouts standard 1| list  or single .|
|Output format|The output format (e.g., html , rss ).|
|Layouts standard 2| all .|
|Language|The language (e.g., en ).|
|Media type|The media type (e.g., text/html ).|
| Page path |The page path (e.g., /blog/mypost ).|
|Type| type  set in front matter. 2 |

Shortcodes
  • Predefined chunks of HTML code that you can insert into the markdown files.

  • ((< shortcode-name param1 >))

  • Hugo comes will some shortcodes predefined:

    • ((< youtube j11Nm4i4XbI >))

      • This is the id for the youtube video of oppenheimer ost.

Emojis
Numbered List / Ordered List
  • .

Themes

  • Hugo Themes are made up of Hugo Layouts.

  • The themes  directory contains one or more themes, each in its own subdirectory.

Installing a Theme
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo "theme = 'ananke'" >> hugo.toml
    # This didn't work. I just placed the string manually
Docs "Modern"
  • https://themes.gohugo.io/themes/e25dx/

    • Meio funcional, meio moderno

    • Ao testar:

      • Hmmmm idk.

      • NΓ£o parece me dar basicamente nenhuma configuraΓ§Γ£o, sΓ³ o que de fato tΓ‘ na demo.

  • https://themes.gohugo.io/themes/docura/

    • DocumentaΓ§Γ£o legal, mas meio Swift.

  • https://themes.gohugo.io/themes/hextra/

    • DocumentaΓ§Γ£o legal, mas meio Swift.

  • https://themes.gohugo.io/themes/doks/

    • DocumentaΓ§Γ£o legal, mas meio Swift.

  • https://themes.gohugo.io/themes/theme-documentation/

    • DocumentaΓ§Γ£o legal, mas meio Swift.

  • https://themes.gohugo.io/themes/lotusdocs/

    • DocumentaΓ§Γ£o legal, mas meio Swift, meio poluido.

Docs Funcionais
  • https://themes.gohugo.io/themes/hugo-theme-relearn/

  • https://themes.gohugo.io/themes/hugo-theme-techdoc/

  • https://themes.gohugo.io/themes/dark-theme-editor/

Blogs
  • https://themes.gohugo.io/themes/gohugo-theme-ananke/

    • Mais simples de navegar do que o CleanWhite.

  • https://themes.gohugo.io/themes/archie/

    • https://athul.github.io/archie/

    • Achei meio confuso de navegar.

  • https://themes.gohugo.io/themes/hugo-theme-console/

    • https://mrmierzejewski.com/hugo-theme-console/

    • Achei meio confuso de navegar.

  • https://themes.gohugo.io/themes/hugo-theme-terminalcv/

    • https://coolapso.sh/

    • Divertidinho, mas acho que assim que sai do terminal, o treco fica meio bugado e perde a temΓ‘tica.

  • https://themes.gohugo.io/themes/hugo-theme-next/

    • Meio poluido.

  • https://themes.gohugo.io/themes/hugo-theme-cleanwhite/

    • https://www.zhaohuabing.com/categories/tech/

    • Acho meio confuso de navegar.

  • https://themes.gohugo.io/themes/poison/

    • Muito bΓ‘sico, simplesmente.

  • https://themes.gohugo.io/themes/hugo-paper/

    • Muito bΓ‘sico, simplesmente.

Stylized
  • https://themes.gohugo.io/themes/neopost/

  • https://themes.gohugo.io/themes/hugo-theme-reimu/

Portfolio /  Curriculo
  • https://themes.gohugo.io/themes/adritian-free-hugo-theme/

  • https://nicokaiser.github.io/hugo-theme-gallery/

    • Bacana.

  • https://themes.gohugo.io/themes/hugo-theme-dream/

    • Meio google, empresa bilhonΓ‘ria, chato.

  • https://staticbattery.com/

  • https://themes.gohugo.io/themes/simple-snipcart-shop/

Publish

static
  • The static  directory contains files that will be copied to the public  directory when you build your site.

  • For example: favicon.ico , robots.txt , and files that verify site ownership.

  • Before the introduction of page bundles  and asset pipelines , the static  directory was also used for images, CSS, and JavaScript.

public
  • The public  directory contains the published website, generated when you run the hugo  or hugo server  commands.

  • Hugo recreates this directory and its content as needed.

  • SeeΒ  details .

resources
  • The resources  directory contains cached output from Hugo’s asset pipelines, generated when you run the hugo  or hugo server  commands.

  • By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed.

Host Locally
  • Used to view your site while developing layouts or creating content

hugo server
    # Only worked for hugo extended.
  • Life Reload :

    • While the server is running, it watches your project directory for changes to assets, configuration, content, data, layouts, translations, and static files. When it detects a change, the server rebuilds your site and refreshes your browser using LiveReload .

    • While the server is running, Hugo injects JavaScript into the generated HTML pages. The LiveReload script creates a connection from the browser to the server via web sockets. You do not need to install any software or browser plugins, nor is any configuration required.

    • Automatic Redirection :

      • If you want your browser to automatically redirect to the page you last modified, run:

      hugo server --navigateToChanged
      
  • New notes are created as drafts. If you want to see those, use:

hugo server --buildDrafts
Host Remote
Publish
hugo
  • Directories :

    • Default publish directory:

      • /public .

    • To publish your site to a different directory, use the --destination  flag or set publishDir  in your site configuration.

    • This is also used, I think:

      • /resources .

  • Inside the /public :

    public/
    β”œβ”€β”€ categories/
    β”‚   β”œβ”€β”€ index.html
    β”‚   └── index.xml  <-- RSS feed for this section
    β”œβ”€β”€ posts/
    β”‚   β”œβ”€β”€ my-first-post/
    β”‚   β”‚   └── index.html
    β”‚   β”œβ”€β”€ index.html
    β”‚   └── index.xml  <-- RSS feed for this section
    β”œβ”€β”€ tags/
    β”‚   β”œβ”€β”€ index.html
    β”‚   └── index.xml  <-- RSS feed for this section
    β”œβ”€β”€ index.html
    β”œβ”€β”€ index.xml      <-- RSS feed for the site
    └── sitemap.xml
    
  • Watch out! :

    • Hugo does not  clear the public  directory before building your site. Depending on the current  evaluation of the four conditions above, after the build your public  directory may contain extraneous files from a previous build.

    • A common practice is to manually clear the contents of the public  directory before each build to remove draft, expired, and future content.

Union File System
  • Hugo creates a union file system, allowing you to mount two or more directories to the same location.

  • For example, let’s say your home directory contains a Hugo project in one directory, and shared content in another:

home/
└── user/
    β”œβ”€β”€ my-site/            
    β”‚   β”œβ”€β”€ content/
    β”‚   β”‚   β”œβ”€β”€ books/
    β”‚   β”‚   β”‚   β”œβ”€β”€ _index.md
    β”‚   β”‚   β”‚   β”œβ”€β”€ book-1.md
    β”‚   β”‚   β”‚   └── book-2.md
    β”‚   β”‚   └── _index.md
    β”‚   β”œβ”€β”€ themes/
    β”‚   β”‚   └── my-theme/
    β”‚   └── hugo.toml
    β””── shared-content/     
        β””── films/
            β”œβ”€β”€ _index.md
            β”œβ”€β”€ film-1.md
            β””── film-2.md
  • You can include the shared content when you build your site using mounts. In your site configuration:

[module]
  [module.mounts](module.mounts)
    source = 'content'
    target = 'content'
  [module.mounts](module.mounts)
    source = '/home/user/shared-content'
    target = 'content'
  • When you overlay one directory on top of another, you must mount both directories.

  • Hugo does not follow symbolic links. If you need the functionality provided by symbolic links, use Hugo’s union file system instead.

  • After mounting, the union file system has this structure:

home/
└── user/
    β””── my-site/
        β”œβ”€β”€ content/
        β”‚   β”œβ”€β”€ books/
        β”‚   β”‚   β”œβ”€β”€ _index.md
        β”‚   β”‚   β”œβ”€β”€ book-1.md
        β”‚   β”‚   └── book-2.md
        β”‚   β”œβ”€β”€ films/
        β”‚   β”‚   β”œβ”€β”€ _index.md
        β”‚   β”‚   β”œβ”€β”€ film-1.md
        β”‚   β”‚   └── film-2.md
        β”‚   └── _index.md
        β”œβ”€β”€ themes/
        β”‚   └── my-theme/
        β””── hugo.toml
  • When two or more files have the same path, the order of precedence follows the order of the mounts. For example, if the shared content directory contains books/book-1.md , it will be ignored because the project’s content  directory was mounted first.

  • You can mount directories to archetypes , assets , content , data , i18n , layouts , and static . SeeΒ  details .

  • You can also mount directories from Git repositories using Hugo Modules. SeeΒ  details .