static
-
The
staticdirectory contains files that will be copied to thepublicdirectory when you build your site. -
For example:
favicon.ico,robots.txt, and files that verify site ownership. -
Before the introduction of page bundles and asset pipelines , the
staticdirectory was also used for images, CSS, and JavaScript.
public
-
The
publicdirectory contains the published website, generated when you run thehugoorhugo 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 thehugoorhugo servercommands. -
By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed.
Host Locally
-
Used to view your site while developing layouts or creating content
hugo server
# Only worked for hugo extended.
-
Life Reload :
-
While the server is running, it watches your project directory for changes to assets, configuration, content, data, layouts, translations, and static files. When it detects a change, the server rebuilds your site and refreshes your browser using LiveReload .
-
While the server is running, Hugo injects JavaScript into the generated HTML pages. The LiveReload script creates a connection from the browser to the server via web sockets. You do not need to install any software or browser plugins, nor is any configuration required.
-
Automatic Redirection :
-
If you want your browser to automatically redirect to the page you last modified, run:
hugo server --navigateToChanged -
-
-
New notes are created as drafts. If you want to see those, use:
hugo server --buildDrafts
Host Remote
Publish
hugo
-
Directories :
-
Default publish directory:
-
/public.
-
-
To publish your site to a different directory, use the
--destinationflag or setpublishDirin your site configuration. -
This is also used, I think:
-
/resources.
-
-
-
Inside the
/public:public/ βββ categories/ β βββ index.html β βββ index.xml <-- RSS feed for this section βββ posts/ β βββ my-first-post/ β β βββ index.html β βββ index.html β βββ index.xml <-- RSS feed for this section βββ tags/ β βββ index.html β βββ index.xml <-- RSS feed for this section βββ index.html βββ index.xml <-- RSS feed for the site βββ sitemap.xml-
In a simple hosting environment, where you typically
ftp,rsync, orscpyour files to the root of a virtual host, the contents of thepublicdirectory are all that you need. -
Most of our users deploy their sites using a CI/CD workflow, where a push 1 to their GitHub or GitLab repository triggers a build and deployment. Popular providers include AWS Amplify , CloudCannon , Cloudflare Pages , GitHub Pages , GitLab Pages , and Netlify .
-
-
Watch out! :
-
Hugo does not clear the
publicdirectory before building your site. Depending on the current evaluation of the four conditions above, after the build yourpublicdirectory may contain extraneous files from a previous build. -
A common practice is to manually clear the contents of the
publicdirectory before each build to remove draft, expired, and future content.
-
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-site/
β βββ 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.md
-
You can include the shared content when you build your site using mounts. In your site configuration:
[module]
[module.mounts](module.mounts)
source = 'content'
target = 'content'
[module.mounts](module.mounts)
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-site/
βββ 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.toml
-
When 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βscontentdirectory was mounted first. -
You can mount directories to
archetypes,assets,content,data,i18n,layouts, andstatic. SeeΒ details . -
You can also mount directories from Git repositories using Hugo Modules. SeeΒ details .