成為我們的資助者或贊助商,以支持我們的工作。
這篇文章包含了如何在 Netlify 上部署網站的分步說明。
可以通過多種方式於 Netlify 部署站點,本文只對基於文件配置的部署方式,其比控制檯設置更靈活。
首先創建以下配置文件,然後提交到你的倉庫。
1[build]
2command = "npm ci && hugo --minify --gc -b $URL"
3publish = "public"
4
5[build.environment]
6NODE_VERSION = "19"
7HUGO_VERSION = "0.121.2"
8HUGO_ENABLEGITINFO = "true"
9HUGO_ENV = "production"
10GO_VERSION = "1.20"
11
12[[headers]]
13 for = "/*"
14 [headers.values]
15 Referrer-Policy = "strict-origin-when-cross-origin"
16 X-Content-Type-Options = "nosniff"
17 X-Frame-Options = "deny"
18 X-XSS-Protection = "1; mode=block"
19
20# multilingual 404 pages, remove it on monolingual sites.
21[[redirects]]
22 from = "/en/*"
23 to = "/en/404.html"
24 status = 404
25
26[[redirects]]
27 from = "/zh-hans/*"
28 to = "/zh-hans/404.html"
29 status = 404
30
31# fallback 404 page.
32[[redirects]]
33 from = "/*"
34 to = "/404.html"
35 # to = "/en/404.html" # use this instead if defaultContentLanguageInSubdir is enabled.
36 status = 404
Import an existing project
。netlify.toml
中配置。