Archetypes
-
The
archetypesdirectory 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.mdwill be the template forcontent/dir1files.
-
-
For:
hugo new content posts/my-first-post.md -
The archetype lookup order is:
-
archetypes/posts.md -
archetypes/default.md -
themes/my-theme/archetypes/posts.md -
themes/my-theme/archetypes/default.md
-
-
If none of these exists, Hugo uses a built-in default archetype.
-
-
Explicit Archetype :
-
Use the
--kindcommand line flag to specify an archetype when creating content. -
Ex :
-
To create an article using the
articlesarchetype:
hugo new content articles/something.md-
To create an article using the
tutorialsarchetype:
hugo new content --kind tutorials articles/something.md -
-
Content
-
The
contentdirectory 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
draftvalue istrue -
The
dateis in the future -
The
publishDateis in the future -
The
expiryDateis 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
cascadefront matter field to cascade build options to the descendant pages.
URL
-
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
staticfolder andcontentfolder 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.pngwill be in the same folder as the note.
-
Images
-
-
"Workarounds for things not officially supported by Markdown."
-
-
-
Everything involves templates, which I hate for low compatibility.
-
-
-
Everything involves templates, which I hate for low compatibility.
-
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
assetsdirectory contains global resources typically passed through an asset pipeline. -
This includes resources such as images, CSS, Sass, JavaScript, and TypeScript.
-
SeeΒ details .
data
-
The
datadirectory 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
Datamethod on aSiteobject.