Debian Codegraph @

docs/content/en/getting-started/directory-structure.md

raw
1 ---
2 title: Directory structure
3 description: An overview of Hugo's directory structure.
4 categories: []
5 keywords: []
6 weight: 30
7 aliases: [/overview/source-directory/]
8 ---
9
10 Each Hugo project is a directory, with subdirectories that contribute to content, structure, behavior, and presentation.
11
12 ## Project skeleton
13
14 Hugo generates a project skeleton when you create a new project. For example, this command:
15
16 ```sh
17 hugo new project my-project
18 ```
19
20 Creates this directory structure:
21
22 ```txt
23 my-project/
24 ├── archetypes/
25 │ └── default.md
26 ├── assets/
27 ├── content/
28 ├── data/
29 ├── i18n/
30 ├── layouts/
31 ├── static/
32 ├── themes/
33 └── hugo.toml <-- project configuration
34 ```
35
36 Depending on requirements, you may wish to organize your project configuration into subdirectories:
37
38 ```txt
39 my-project/
40 ├── archetypes/
41 │ └── default.md
42 ├── assets/
43 ├── config/ <-- project configuration
44 │ └── _default/
45 │ └── hugo.toml
46 ├── content/
47 ├── data/
48 ├── i18n/
49 ├── layouts/
50 ├── static/
51 └── themes/
52 ```
53
54 When you build your project, Hugo creates a `public` directory, and typically a `resources` directory as well:
55
56 ```txt
57 my-project/
58 ├── archetypes/
59 │ └── default.md
60 ├── assets/
61 ├── config/
62 │ └── _default/
63 │ └── hugo.toml
64 ├── content/
65 ├── data/
66 ├── i18n/
67 ├── layouts/
68 ├── public/ <-- created when you build your project
69 ├── resources/ <-- created when you build your project
70 ├── static/
71 └── themes/
72 ```
73
74 ## Directories
75
76 Each of the subdirectories contributes to content, structure, behavior, or presentation.
77
78 `archetypes`
79 : The `archetypes` directory contains templates for new content. See [details](/content-management/archetypes/).
80
81 `assets`
82 : 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](/hugo-pipes/introduction/).
83
84 `config`
85 : The `config` directory 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 named `hugo.toml` in the root of the project is sufficient. See [details][configuration-directory].
86
87 `content`
88 : The `content` directory contains the markup files (typically Markdown) and page resources that comprise the content of your project. See [details](/content-management/organization/).
89
90 `data`
91 : The `data` directory contains data files (JSON, TOML, YAML, or XML) that augment content, configuration, localization, and navigation. See [details](/content-management/data-sources/).
92
93 `i18n`
94 : The `i18n` directory contains translation tables for multilingual projects. See [details](/content-management/multilingual/).
95
96 `layouts`
97 : The `layouts` directory contains templates to transform content, data, and resources into a complete website. See [details](/templates/).
98
99 `public`
100 : The `public` directory contains the published website, generated when you run the `hugo build` or `hugo server` commands. Hugo recreates this directory and its content as needed. See [details][build-your-project].
101
102 `resources`
103 : The `resources` directory contains cached output from Hugo's asset pipelines, generated when you run the `hugo build` or `hugo server` commands. By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed.
104
105 `static`
106 : The `static` directory contains files that will be copied to the `public` directory when you build your project. For example: `favicon.ico`, `robots.txt`, and files that verify website ownership. Before the introduction of [page bundles](g) and [asset pipelines][], the `static` directory was also used for images, CSS, and JavaScript.
107
108 `themes`
109 : The `themes` directory contains one or more [themes](g), each in its own subdirectory.
110
111 ## Unified file system
112
113 Hugo creates a [unified file system](g), 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:
114
115 ```tree
116 home/
117 └── user/
118 ├── my-project/
119 │ ├── content/
120 │ │ ├── books/
121 │ │ │ ├── _index.md
122 │ │ │ ├── book-1.md
123 │ │ │ └── book-2.md
124 │ │ └── _index.md
125 │ ├── themes/
126 │ │ └── my-theme/
127 │ └── hugo.toml
128 └── shared-content/
129 └── films/
130 ├── _index.md
131 ├── film-1.md
132 └── film-2.md
133 ```
134
135 You can include the shared content using mounts. In your project configuration:
136
137 {{< code-toggle file=hugo >}}
138 [[module.mounts]]
139 source = 'content'
140 target = 'content'
141
142 [[module.mounts]]
143 source = '/home/user/shared-content'
144 target = 'content'
145 {{< /code-toggle >}}
146
147 > [!NOTE]
148 > Defining a custom mount replaces the default mounting for that [component](g). To overlay an external directory on top of the project default, you must explicitly mount both.
149 >
150 > Hugo does not follow symbolic links. If you need the functionality provided by symbolic links, use Hugo's unified file system instead.
151
152 After mounting, the unified file system has this structure:
153
154 ```tree
155 home/
156 └── user/
157 └── my-project/
158 ├── content/
159 │ ├── books/
160 │ │ ├── _index.md
161 │ │ ├── book-1.md
162 │ │ └── book-2.md
163 │ ├── films/
164 │ │ ├── _index.md
165 │ │ ├── film-1.md
166 │ │ └── film-2.md
167 │ └── _index.md
168 ├── themes/
169 │ └── my-theme/
170 └── hugo.toml
171 ```
172
173 When two or more files share the same path, the version in the highest layer takes precedence. In the example above, if the `shared-content` directory contains `books/book-1.md`, it is ignored because the project's `content` directory is the first (highest) mount.
174
175 You can mount directories to `archetypes`, `assets`, `content`, `data`, `i18n`, `layouts`, and `static`. See [details][mounts].
176
177 You can also mount directories from Git repositories using modules. See [details](/hugo-modules/).
178
179 ## Theme skeleton
180
181 Hugo generates a functional theme skeleton when you create a new theme. For example, this command:
182
183 ```sh
184 hugo new theme my-theme
185 ```
186
187 Creates this directory structure (subdirectories not shown):
188
189 ```tree
190 my-theme/
191 ├── archetypes/
192 ├── assets/
193 ├── content/
194 ├── data/
195 ├── i18n/
196 ├── layouts/
197 ├── static/
198 └── hugo.toml
199 ```
200
201 Using the unified 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.
202
203 If you are simultaneously using components from two or more themes or modules, and there's a path collision, the first mount takes precedence.
204
205 [asset pipelines]: /hugo-pipes/introduction/
206 [build-your-project]: /getting-started/usage/#build-your-project
207 [configuration-directory]: /configuration/introduction/#configuration-directory
208 [mounts]: /configuration/module/#mounts