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.