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

94 lines
4.7 KiB
Markdown
Raw Normal View History

---
title: Directory Structure
linktitle: Directory Structure
description: Hugo's CLI scaffolds a project directory structure and then takes that single directory and uses it as the input to create a complete website.
date: 2017-01-02
publishdate: 2017-02-01
lastmod: 2017-03-09
categories: [getting started,fundamentals]
keywords: [source, organization, directories]
menu:
docs:
parent: "getting-started"
weight: 50
weight: 50
sections_weight: 50
draft: false
aliases: [/overview/source-directory/]
toc: true
---
## New Site Scaffolding
{{< youtube sB0HLHjgQ7E >}}
Running the `hugo new site` generator from the command line will create a directory structure with the following elements:
```
.
├── archetypes
Squashed 'docs/' changes from 0c3c04fd6..540aeddc7 540aeddc7 Small fixes for Open Graph internal template 47bbb3fd7 Bump lodash.template from 4.4.0 to 4.5.0 in /themes/gohugoioTheme 64c1cc3db Update title.md 36c27be37 Update configuration.md 4627cfe9a added commento.io to the list 341d9d945 Fix link to font assets 4a6876dec Small typo fix in configuration.md 736d6ddd7 Add bypasscensorship.org showcase. de7ab636b Use actual width in image processing examples 6c88ab2da Update directory-structure.md 88f559e81 Fix spelling mistakes 7bd427141 Rephrase four points from Hosting on Github docs bce1b1832 Fix typos for absLangURL and relLangURL functions abab57335 Update directory-structure.md a6716f2ed Fix metadata list 5ef61d912 Fix typo d9e467b8b Actuall show how to generate pages in quickstart 0aadc92e7 Update link to issue theme submission b1902faaa Remove incorrect note about Hugo snap --classic use. d451e7362 Update documentation on page variables ab2233c39 Update publish_to_ghpages.sh 7c120346b Fix typo in syntax highlighting page. f01dc555d Correct some typos be825ade9 Videos plural produces og:video bc962fbdf Updated installing.md file to include linuxbrew installation 08c9f8fc8 Mention 1 MB file size limit in readFile doc 7145e29e2 Fixes bad URL in menus.md for .hasChildren * part of issue #814 0edbd59c4 add warning about .Hugo variable being deprecated 77f74ced5 fix: typo in output-formats.md f71b67f34 Correct typo "RFC339" to "RFC1123Z" (#837) 424c0207a baseurl -> baseURL f4e24a03e Render launched; no invite code needed 37e1101d3 Add Render hosting guide 01d0a6481 Bump js-yaml from 3.12.0 to 3.13.1 in /themes/gohugoioTheme edb7b36b0 Link site hierarchy schema to larger version af72acda0 Fixes typo in fingerprint.md 0a738467b Adding required XML tag to sample templates 52211f656 Remove note that XML declaration is not needed a39b9ac87 Adding required XML tag to sample templates 1a44d8a50 Add configuration information for Azure 5b7c6b5a1 remove google plus 5a64301ba HTTPS link to yaml.org/spec/ git-subtree-dir: docs git-subtree-split: 540aeddc797658a2c3d0e49e944592d2b23b3bb8
2019-07-15 21:49:41 +00:00
├── config.toml
├── content
├── data
├── layouts
├── static
└── themes
```
## Directory Structure Explained
The following is a high-level overview of each of the directories with links to each of their respective sections within the Hugo docs.
[`archetypes`](/content-management/archetypes/)
: You can create new content files in Hugo using the `hugo new` command.
By default, Hugo will create new content files with at least `date`, `title` (inferred from the file name), and `draft = true`. This saves time and promotes consistency for sites using multiple content types. You can create your own [archetypes][] with custom preconfigured front matter fields as well.
[`assets`][]
Squashed 'docs/' changes from 0c3c04fd6..540aeddc7 540aeddc7 Small fixes for Open Graph internal template 47bbb3fd7 Bump lodash.template from 4.4.0 to 4.5.0 in /themes/gohugoioTheme 64c1cc3db Update title.md 36c27be37 Update configuration.md 4627cfe9a added commento.io to the list 341d9d945 Fix link to font assets 4a6876dec Small typo fix in configuration.md 736d6ddd7 Add bypasscensorship.org showcase. de7ab636b Use actual width in image processing examples 6c88ab2da Update directory-structure.md 88f559e81 Fix spelling mistakes 7bd427141 Rephrase four points from Hosting on Github docs bce1b1832 Fix typos for absLangURL and relLangURL functions abab57335 Update directory-structure.md a6716f2ed Fix metadata list 5ef61d912 Fix typo d9e467b8b Actuall show how to generate pages in quickstart 0aadc92e7 Update link to issue theme submission b1902faaa Remove incorrect note about Hugo snap --classic use. d451e7362 Update documentation on page variables ab2233c39 Update publish_to_ghpages.sh 7c120346b Fix typo in syntax highlighting page. f01dc555d Correct some typos be825ade9 Videos plural produces og:video bc962fbdf Updated installing.md file to include linuxbrew installation 08c9f8fc8 Mention 1 MB file size limit in readFile doc 7145e29e2 Fixes bad URL in menus.md for .hasChildren * part of issue #814 0edbd59c4 add warning about .Hugo variable being deprecated 77f74ced5 fix: typo in output-formats.md f71b67f34 Correct typo "RFC339" to "RFC1123Z" (#837) 424c0207a baseurl -> baseURL f4e24a03e Render launched; no invite code needed 37e1101d3 Add Render hosting guide 01d0a6481 Bump js-yaml from 3.12.0 to 3.13.1 in /themes/gohugoioTheme edb7b36b0 Link site hierarchy schema to larger version af72acda0 Fixes typo in fingerprint.md 0a738467b Adding required XML tag to sample templates 52211f656 Remove note that XML declaration is not needed a39b9ac87 Adding required XML tag to sample templates 1a44d8a50 Add configuration information for Azure 5b7c6b5a1 remove google plus 5a64301ba HTTPS link to yaml.org/spec/ git-subtree-dir: docs git-subtree-split: 540aeddc797658a2c3d0e49e944592d2b23b3bb8
2019-07-15 21:49:41 +00:00
: Stores all the files which need be processed by [Hugo Pipes]({{< ref "/hugo-pipes" >}}). Only the files whose `.Permalink` or `.RelPermalink` are used will be published to the `public` directory. Note: assets directory is not created by default.
Squashed 'docs/' changes from 785e375f..49809a03 49809a03 Merge commit '20a631b4964fc0ab9137cce1e41774cbc17de044' 20a631b4 Squashed 'themes/gohugoioTheme/' changes from b8202f539..dafc91ff1 8b58f565 Re-generate CLI docs 4653a724 Add Netlify deployment badge 2d6246bc Remove some deprecated site variables e6777153 Improve Algolia Search Display Styling 1570999f Add missing "." in front of gitlab-ci.yaml example b922ae7d This adds documentation to the new configDir/Environment logic from .53 (#729) 7cff379f Correctly escape multi-word taxonomy terms in example 2dfeeda4 fix typo by removing stray paren 0870bd9a Fix typo in `paginate` description 91e8be85 Fixes https://github.com/gohugoio/hugo/issues/5609 c1db65ec Make the dummy URL more obvious b4589ff0 Fix a link b73dcb9a Consistently use "posts" as section name in examples 7a56abbc Format definitions a9c6fd9b Minor clarification over the last commit 5c86bdc8 Add alternative instructions for Quick Start for non-git users dafe7ee9 Add Visual Studio Code plug-ins 110ed19e Update HUGO_VERSION 2abd031a Update page.md b332f7b9 Update page.md f5a8c9d4 Update static-files.md 6d0c155c Add note about relative protocol URLs a13751ac Theme Warning: Remove note about unquoted URLs 4c8f7d68 Incorporate feedback 6f2b9cf0 Update Creating Themes Warning 40d88d98 Fix ToC example to use binary true/false 4a11f3f1 Fix typo 2dbfc0a4 Fix a typo in taxonomies d63790ef Do not mark UndocumentedFeature issues as stale d7aff095 Regenerate docs.json 71c0826f Update transform.Unmarshal.md git-subtree-dir: docs git-subtree-split: 49809a038b2691637bab7f3f2e385dde654a88b8
2019-02-01 08:01:04 +00:00
[`config`](/getting-started/configuration/)
: Hugo ships with a large number of [configuration directives](https://gohugo.io/getting-started/configuration/#all-variables-yaml).
The [config directory](/getting-started/configuration/#configuration-directory) is where those directives are stored as JSON, YAML, or TOML files. Every root setting object can stand as its own file and structured by environments.
Projects with minimal settings and no need for environment awareness can use a single `config.toml` file at its root.
Squashed 'docs/' changes from 0c3c04fd6..540aeddc7 540aeddc7 Small fixes for Open Graph internal template 47bbb3fd7 Bump lodash.template from 4.4.0 to 4.5.0 in /themes/gohugoioTheme 64c1cc3db Update title.md 36c27be37 Update configuration.md 4627cfe9a added commento.io to the list 341d9d945 Fix link to font assets 4a6876dec Small typo fix in configuration.md 736d6ddd7 Add bypasscensorship.org showcase. de7ab636b Use actual width in image processing examples 6c88ab2da Update directory-structure.md 88f559e81 Fix spelling mistakes 7bd427141 Rephrase four points from Hosting on Github docs bce1b1832 Fix typos for absLangURL and relLangURL functions abab57335 Update directory-structure.md a6716f2ed Fix metadata list 5ef61d912 Fix typo d9e467b8b Actuall show how to generate pages in quickstart 0aadc92e7 Update link to issue theme submission b1902faaa Remove incorrect note about Hugo snap --classic use. d451e7362 Update documentation on page variables ab2233c39 Update publish_to_ghpages.sh 7c120346b Fix typo in syntax highlighting page. f01dc555d Correct some typos be825ade9 Videos plural produces og:video bc962fbdf Updated installing.md file to include linuxbrew installation 08c9f8fc8 Mention 1 MB file size limit in readFile doc 7145e29e2 Fixes bad URL in menus.md for .hasChildren * part of issue #814 0edbd59c4 add warning about .Hugo variable being deprecated 77f74ced5 fix: typo in output-formats.md f71b67f34 Correct typo "RFC339" to "RFC1123Z" (#837) 424c0207a baseurl -> baseURL f4e24a03e Render launched; no invite code needed 37e1101d3 Add Render hosting guide 01d0a6481 Bump js-yaml from 3.12.0 to 3.13.1 in /themes/gohugoioTheme edb7b36b0 Link site hierarchy schema to larger version af72acda0 Fixes typo in fingerprint.md 0a738467b Adding required XML tag to sample templates 52211f656 Remove note that XML declaration is not needed a39b9ac87 Adding required XML tag to sample templates 1a44d8a50 Add configuration information for Azure 5b7c6b5a1 remove google plus 5a64301ba HTTPS link to yaml.org/spec/ git-subtree-dir: docs git-subtree-split: 540aeddc797658a2c3d0e49e944592d2b23b3bb8
2019-07-15 21:49:41 +00:00
Many sites may need little to no configuration, but Hugo ships with a large number of [configuration directives][] for more granular directions on how you want Hugo to build your website. Note: config directory is not created by default.
[`content`][]
: All content for your website will live inside this directory. Each top-level folder in Hugo is considered a [content section][]. For example, if your site has three main sections---`blog`, `articles`, and `tutorials`---you will have three directories at `content/blog`, `content/articles`, and `content/tutorials`. Hugo uses sections to assign default [content types][].
[`data`](/templates/data-templates/)
: This directory is used to store configuration files that can be
used by Hugo when generating your website. You can write these files in YAML, JSON, or TOML format. In addition to the files you add to this folder, you can also create [data templates][] that pull from dynamic content.
[`layouts`][]
: Stores templates in the form of `.html` files that specify how views of your content will be rendered into a static website. Templates include [list pages][lists], your [homepage][], [taxonomy templates][], [partials][], [single page templates][singles], and more.
[`static`][]
: Stores all the static content: images, CSS, JavaScript, etc. When Hugo builds your site, all assets inside your static directory are copied over as-is. A good example of using the `static` folder is for [verifying site ownership on Google Search Console][searchconsole], where you want Hugo to copy over a complete HTML file without modifying its content.
{{% note %}}
From **Hugo 0.31** you can have multiple static directories.
{{% /note %}}
[archetypes]: /content-management/archetypes/
[configuration directives]: /getting-started/configuration/#all-variables-yaml
[`content`]: /content-management/organization/
[content section]: /content-management/sections/
[content types]: /content-management/types/
[data templates]: /templates/data-templates/
[homepage]: /templates/homepage/
[`layouts`]: /templates/
[`static`]: /content-management/static-files/
[lists]: /templates/list/
[pagevars]: /variables/page/
[partials]: /templates/partials/
[searchconsole]: https://support.google.com/analytics/answer/1142414?hl=en
[singles]: /templates/single-page-templates/
[starters]: /tools/starter-kits/
[taxonomies]: /content-management/taxonomies/
[taxonomy templates]: /templates/taxonomy-templates/
[types]: /content-management/types/
[`assets`]: {{< ref "/hugo-pipes/introduction#asset-directory" >}}