Directory structure
Each Hugo project is a directory, with subdirectories that contribute to content, structure, behavior, and presentation.
Project skeleton
Hugo generates a project skeleton when you create a new project. For example, this command:
hugo new project my-projectCreates this directory structure:
my-project/
├── archetypes/
│ └── default.md
├── assets/
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
├── themes/
└── hugo.toml <-- project configurationDepending on requirements, you may wish to organize your project configuration into subdirectories:
my-project/
├── archetypes/
│ └── default.md
├── assets/
├── config/ <-- project configuration
│ └── _default/
│ └── hugo.toml
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
└── themes/When you build your project, Hugo creates a public directory, and typically a resources directory as well:
my-project/
├── archetypes/
│ └── default.md
├── assets/
├── config/
│ └── _default/
│ └── hugo.toml
├── content/
├── data/
├── i18n/
├── layouts/
├── public/ <-- created when you build your project
├── resources/ <-- created when you build your project
├── static/
└── themes/Directories
Each of the subdirectories contributes to content, structure, behavior, or presentation.
- archetypes
- The
archetypesdirectory contains templates for new content. See details. - 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. - config
- The
configdirectory contains your project configuration, possibly split into multiple subdirectories and files. For projects with minimal configuration or projects that do not need to behave differently in different environments, a single configuration file namedhugo.tomlin the root of the project is sufficient. See details. - content
- The
contentdirectory contains the markup files (typically Markdown) and page resources that comprise the content of your project. See details. - data
- The
datadirectory contains data files (JSON, TOML, YAML, or XML) that augment content, configuration, localization, and navigation. See details. - i18n
- The
i18ndirectory contains translation tables for multilingual projects. See details. - layouts
- The
layoutsdirectory contains templates to transform content, data, and resources into a complete website. See details. - public
- The
publicdirectory contains the published website, generated when you run thehugo buildorhugo servercommands. Hugo recreates this directory and its content as needed. See details. - resources
- The
resourcesdirectory contains cached output from Hugo’s asset pipelines, generated when you run thehugo buildorhugo servercommands. By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed. - static
- The
staticdirectory contains files that will be copied to thepublicdirectory when you build your project. For example:favicon.ico,robots.txt, and files that verify website ownership. Before the introduction of page bundles and asset pipelines, thestaticdirectory was also used for images, CSS, and JavaScript. - themes
- The
themesdirectory contains one or more themes, each in its own subdirectory.
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-project/
│ ├── 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.mdYou can include the shared content using mounts. In your project configuration:
module:
mounts:
- source: content
target: content
- source: /home/user/shared-content
target: content
[module]
[[module.mounts]]
source = 'content'
target = 'content'
[[module.mounts]]
source = '/home/user/shared-content'
target = 'content'
{
"module": {
"mounts": [
{
"source": "content",
"target": "content"
},
{
"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-project/
├── 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.tomlWhen 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.
Theme skeleton
Hugo generates a functional theme skeleton when you create a new theme. For example, this command:
hugo new theme my-themeCreates this directory structure (subdirectories not shown):
my-theme/
├── archetypes/
├── assets/
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
└── hugo.tomlUsing the union file system described above, Hugo mounts each of these directories to the corresponding location in the project. When two files have the same path, the file in the project directory takes precedence. This allows you, for example, to override a theme’s template by placing a copy in the same location within the project directory.
If you are simultaneously using components from two or more themes or modules, and there’s a path collision, the first mount takes precedence.
