Update hugo_build.md

This commit is contained in:
dush aine 2025-07-29 18:07:08 +02:00 committed by GitHub
parent 97e035006b
commit 6f0aaa18e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,72 +1,98 @@
--- # Hugo Build Command
title: "hugo build"
slug: hugo_build
url: /commands/hugo_build/
---
## hugo build
Build your site Build your Hugo site with speed and flexibility.
### Synopsis ## Overview
build is the main command, used to build your Hugo site. The `hugo build` command generates your static site, transforming your content and templates into a ready-to-deploy set of files. Hugo, a fast and flexible static site generator built in Go, makes this process efficient and customizable.
Hugo is a Fast and Flexible Static Site Generator For full documentation, visit [gohugo.io](https://gohugo.io)
built with love by spf13 and friends in Go.
Complete documentation is available at https://gohugo.io/. ## Usage
``` ```bash
hugo build [flags] hugo build [flags]
``` ```
### Options ## Key Features
``` - ⚡ **Fast Builds**: Generate your site in milliseconds
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - 🛠️ **Flexible Options**: Customize the build process with flags for drafts, caching, minification, and more
-D, --buildDrafts include content marked as draft - 🔄 **Watch Mode**: Rebuild automatically when files change using the `--watch` flag
-E, --buildExpired include expired content - 🌐 **Environment Support**: Tailor builds for different environments (e.g., development, production)
-F, --buildFuture include content with publishdate in the future
--cacheDir string filesystem path to cache directory ## Command Line Options
--cleanDestinationDir remove files from destination not found in static directories
--clock string set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00 | Flag | Description | Example |
--config string config file (default is hugo.yaml|json|toml) |------|-------------|---------|
--configDir string config dir (default "config") | `-b, --baseURL` | Set the hostname (and path) for the site root | `--baseURL https://example.com/` |
-c, --contentDir string filesystem path to content directory | `-D, --buildDrafts` | Include draft content in the build | `--buildDrafts` |
-d, --destination string filesystem path to write files to | `-E, --buildExpired` | Include expired content in the build | `--buildExpired` |
--disableKinds strings disable different kind of pages (home, RSS etc.) | `-F, --buildFuture` | Include content with a future publish date | `--buildFuture` |
--enableGitInfo add Git revision, date, author, and CODEOWNERS info to the pages | `--cacheDir` | Specify the cache directory path | `--cacheDir /path/to/cache` |
-e, --environment string build environment | `--cleanDestinationDir` | Remove files in destination not found in static directories | `--cleanDestinationDir` |
--forceSyncStatic copy all files when static is changed. | `--clock` | Set a custom time for Hugo (e.g., for testing) | `--clock 2021-11-06T22:30:00.00+09:00` |
--gc enable to run some cleanup tasks (remove unused cache files) after the build | `--config` | Specify a custom config file | `--config custom.yaml` |
-h, --help help for build | `--configDir` | Set the config directory | `--configDir myconfig` |
--ignoreCache ignores the cache directory | `-c, --contentDir` | Specify the content directory path | `--contentDir content` |
--ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern | `-d, --destination` | Set the output directory | `--destination public` |
-l, --layoutDir string filesystem path to layout directory | `--disableKinds` | Disable specific page types (e.g., home, RSS) | `--disableKinds home,rss` |
--logLevel string log level (debug|info|warn|error) | `--enableGitInfo` | Add Git revision, date, author info to pages | `--enableGitInfo` |
--minify minify any supported output format (HTML, XML etc.) | `-e, --environment` | Specify the build environment | `--environment production` |
--noBuildLock don't create .hugo_build.lock file | `--forceSyncStatic` | Copy all static files when changes are detected | `--forceSyncStatic` |
--noChmod don't sync permission mode of files | `--gc` | Run cleanup tasks to remove unused cache files | `--gc` |
--noTimes don't sync modification time of files | `-h, --help` | Display help for the build command | `--help` |
--panicOnWarning panic on first WARNING log | `--ignoreCache` | Bypass the cache directory | `--ignoreCache` |
--poll string set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes | `--ignoreVendorPaths` | Ignore vendor paths matching Glob pattern | `--ignoreVendorPaths **/vendor/**` |
--printI18nWarnings print missing translations | `-l, --layoutDir` | Specify the layout directory path | `--layoutDir layouts` |
--printMemoryUsage print memory usage to screen at intervals | `--logLevel` | Set the log level (debug, info, warn, error) | `--logLevel debug` |
--printPathWarnings print warnings on duplicate target paths etc. | `--minify` | Minify supported output formats (e.g., HTML) | `--minify` |
--printUnusedTemplates print warnings on unused templates. | `--noBuildLock` | Prevent creation of .hugo_build.lock file | `--noBuildLock` |
--quiet build in quiet mode | `--noChmod` | Disable syncing file permission modes | `--noChmod` |
--renderSegments strings named segments to render (configured in the segments config) | `--noTimes` | Disable syncing file modification times | `--noTimes` |
-M, --renderToMemory render to memory (mostly useful when running the server) | `--panicOnWarning` | Stop the build on first WARNING | `--panicOnWarning` |
-s, --source string filesystem path to read files relative from | `--poll` | Set polling interval for file system changes | `--poll 700ms` |
--templateMetrics display metrics about template executions | `--printI18nWarnings` | Print missing translation warnings | `--printI18nWarnings` |
--templateMetricsHints calculate some improvement hints when combined with --templateMetrics | `--printMemoryUsage` | Display memory usage during the build | `--printMemoryUsage` |
-t, --theme strings themes to use (located in /themes/THEMENAME/) | `--printPathWarnings` | Show warnings for duplicate target paths | `--printPathWarnings` |
--themesDir string filesystem path to themes directory | `--printUnusedTemplates` | Show warnings for unused templates | `--printUnusedTemplates` |
--trace file write trace to file (not useful in general) | `--quiet` | Run build in quiet mode (minimal output) | `--quiet` |
-w, --watch watch filesystem for changes and recreate as needed | `--renderSegments` | Render specific named segments | `--renderSegments segment1,segment2` |
| `-M, --renderToMemory` | Render to memory (useful for servers) | `--renderToMemory` |
| `-s, --source` | Set source directory for reading files | `--source src` |
| `--templateMetrics` | Display template execution metrics | `--templateMetrics` |
| `--templateMetricsHints` | Suggest improvements via template metrics | `--templateMetricsHints` |
| `-t, --theme` | Specify themes to use | `--theme mytheme` |
| `--themesDir` | Set themes directory path | `--themesDir themes` |
| `--trace` | Write trace output to a file | `--trace trace.log` |
| `-w, --watch` | Watch for file changes and rebuild | `--watch` |
## Examples
### Basic build
```bash
# Build the site with default settings
hugo build
``` ```
### SEE ALSO ### Build with drafts and minification
```bash
# Include drafts and minify output
hugo build --buildDrafts --minify
```
* [hugo](/commands/hugo/) - Build your site ### Watch mode for development
```bash
# Watch for file changes and rebuild
hugo build --watch
```
### Production build
```bash
# Build for production with custom base URL
hugo build --environment production --baseURL https://example.com/
```
## See Also
- [hugo](https://gohugo.io) - Learn more about the root command and Hugo documentation