| 1 |
--- |
| 2 |
title: "hugo server" |
| 3 |
slug: hugo_server |
| 4 |
url: /commands/hugo_server/ |
| 5 |
--- |
| 6 |
## hugo server |
| 7 |
|
| 8 |
Start the embedded web server |
| 9 |
|
| 10 |
### Synopsis |
| 11 |
|
| 12 |
Hugo provides its own webserver which builds and serves the project. |
| 13 |
While hugo server is high performance, it is a webserver with limited options. |
| 14 |
|
| 15 |
The `hugo server` command will by default write and serve files from disk, but |
| 16 |
you can render to memory by using the `--renderToMemory` flag. This can be |
| 17 |
faster in some cases, but it will consume more memory. |
| 18 |
|
| 19 |
By default hugo will also watch your files for any changes you make and |
| 20 |
automatically rebuild the project. It will then live reload any open browser pages |
| 21 |
and push the latest content to them. As most Hugo projects are built in a fraction |
| 22 |
of a second, you will be able to save and see your changes nearly instantly. |
| 23 |
|
| 24 |
``` |
| 25 |
hugo server [command] [flags] |
| 26 |
``` |
| 27 |
|
| 28 |
### Options |
| 29 |
|
| 30 |
``` |
| 31 |
--appendPort append port to baseURL (default true) |
| 32 |
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ |
| 33 |
--bind string interface to which the server will bind (default "127.0.0.1") |
| 34 |
-D, --buildDrafts include content marked as draft |
| 35 |
-E, --buildExpired include expired content |
| 36 |
-F, --buildFuture include content with publishdate in the future |
| 37 |
--cacheDir string filesystem path to cache directory |
| 38 |
--cleanDestinationDir remove files from destination not found in static directories |
| 39 |
-c, --contentDir string filesystem path to content directory |
| 40 |
--disableBrowserError do not show build errors in the browser |
| 41 |
--disableFastRender enables full re-renders on changes |
| 42 |
--disableKinds strings disable different kind of pages (home, RSS etc.) |
| 43 |
--disableLiveReload watch without enabling live browser reload on rebuild |
| 44 |
--enableGitInfo add Git revision, date, author, and CODEOWNERS info to the pages |
| 45 |
--forceSyncStatic copy all files when static is changed. |
| 46 |
--gc enable to run some cleanup tasks (remove unused cache files) after the build |
| 47 |
-h, --help help for server |
| 48 |
--ignoreCache ignore the configured file caches |
| 49 |
-l, --layoutDir string filesystem path to layout directory |
| 50 |
--liveReloadPort int port for live reloading (i.e. 443 in HTTPS proxy situations) (default -1) |
| 51 |
--minify minify any supported output format (HTML, XML etc.) |
| 52 |
-N, --navigateToChanged navigate to changed content file on live browser reload |
| 53 |
--noChmod don't sync permission mode of files |
| 54 |
--noHTTPCache disable browser caching of pages served by the embedded web server |
| 55 |
--noTimes don't sync modification time of files |
| 56 |
-O, --openBrowser open the project in a browser after server startup |
| 57 |
--panicOnWarning panic on first WARNING log |
| 58 |
--poll string set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes |
| 59 |
-p, --port int port on which the server will listen (default 1313) |
| 60 |
--pprof enable the pprof server (port 8080) |
| 61 |
--printI18nWarnings print missing translations |
| 62 |
--printMemoryUsage print memory usage to screen at intervals |
| 63 |
--printPathWarnings print warnings on duplicate target paths etc. |
| 64 |
--printUnusedTemplates print warnings on unused templates. |
| 65 |
--renderSegments strings named segments to render (configured in the segments config) |
| 66 |
--renderStaticToDisk serve static files from disk and dynamic files from memory |
| 67 |
--templateMetrics display metrics about template executions |
| 68 |
--templateMetricsHints calculate some improvement hints when combined with --templateMetrics |
| 69 |
-t, --theme strings themes to use (located in /themes/THEMENAME/) |
| 70 |
--tlsAuto generate and use locally-trusted certificates. |
| 71 |
--tlsCertFile string path to TLS certificate file |
| 72 |
--tlsKeyFile string path to TLS key file |
| 73 |
--trace file write trace to file (not useful in general) |
| 74 |
-w, --watch watch filesystem for changes and recreate as needed (default true) |
| 75 |
``` |
| 76 |
|
| 77 |
### Options inherited from parent commands |
| 78 |
|
| 79 |
``` |
| 80 |
--clock string set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00 |
| 81 |
--config string config file (default is hugo.yaml|json|toml) |
| 82 |
--configDir string config dir (default "config") |
| 83 |
-d, --destination string filesystem path to write files to |
| 84 |
-e, --environment string build environment |
| 85 |
--ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern |
| 86 |
--logLevel string log level (debug|info|warn|error) |
| 87 |
--noBuildLock don't create .hugo_build.lock file |
| 88 |
--quiet build in quiet mode |
| 89 |
-M, --renderToMemory render to memory (mostly useful when running the server) |
| 90 |
-s, --source string filesystem path to read files relative from |
| 91 |
--themesDir string filesystem path to themes directory |
| 92 |
``` |
| 93 |
|
| 94 |
### SEE ALSO |
| 95 |
|
| 96 |
* [hugo](/commands/hugo/) - Build your project |
| 97 |
* [hugo server trust](/commands/hugo_server_trust/) - Install the local CA in the system trust store |