portails/content/docs/core-hyas/netlify.md

2.4 KiB

title description lead date lastmod draft images menu weight toc
Netlify Deploy to Netlify with sensible defaults. Easily use Netlify Functions, Netlify Redirects, and Netlify Headers. Deploy to Netlify with sensible defaults. Easily use Netlify Functions, Netlify Redirects, and Netlify Headers. 2020-09-21T15:58:12+02:00 2020-09-21T15:58:12+02:00 false
docs
parent
core-hyas
260 true
.
├── assets/
│   └── lambda/
├── layouts/
│   ├── index.headers
│   └── index.redirects
└── netlify.toml

See also the Hugo Docs: Host on Netlify.

Functions

Functions in ./assets/lambda/ are compiled on build to ./functions/.

See also the Netlify docs: Functions overview

Redirects

./layouts/index.redirects is converted on build to ./public/_redirects.

{{ range $pages := .Site.Pages -}}
  {{ range .Aliases -}}
    {{ . }} {{ $pages.RelPermalink -}}
  {{ end -}}
{{ end -}}

See also the Netlify docs: Redirects and rewrites

Headers

./layouts/index.headers is converted on build to ./public/_headers.

/*
  Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  X-Content-Type-Options: nosniff
  X-XSS-Protection: 1; mode=block
  Content-Security-Policy: default-src 'none'; manifest-src 'self'; connect-src 'self'; font-src 'self'; img-src 'self'; script-src 'self'; style-src 'self'
  X-Frame-Options: SAMEORIGIN
  Referrer-Policy: strict-origin
  Feature-Policy: geolocation 'self'
  Cache-Control: public, max-age=31536000

See also the Netlify docs: Custom headers

Build and deploy

./netlify.toml:

[build]
  publish = "public"
  functions = "functions"

[build.environment]
  HUGO_VERSION = "0.74.3"
  NODE_VERSION = "13.11.0"
  NPM_VERSION = "6.13.7"
  YARN_VERSION = "1.22.4"

[context.production]
  command = "hugo -b $URL --gc --minify && npm run build:functions"

[context.deploy-preview]
  command = "hugo -b $DEPLOY_PRIME_URL --gc --minify"

[context.branch-deploy]
  command = "hugo -b $DEPLOY_PRIME_URL --gc --minify"

See also the Netlify docs: File-based configuration