Welcome to mirror list, hosted at ThFree Co, Russian Federation.

netlify.md « core-hyas « docs « content - github.com/h-enk/doks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c43e02b52c5aa1f30922238903015a59567b90b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: "Netlify"
description: "Deploy to Netlify with sensible defaults. Easily use Netlify Functions, Netlify Redirects, and Netlify Headers."
lead: "Deploy to Netlify with sensible defaults. Easily use Netlify Functions, Netlify Redirects, and Netlify Headers."
date: 2020-09-21T15:58:12+02:00
lastmod: 2020-09-21T15:58:12+02:00
draft: false
images: []
menu: 
  docs:
    parent: "core-hyas"
weight: 260
toc: true
---

```bash
.
├── assets/
│   └── lambda/
├── layouts/
│   ├── index.headers
│   └── index.redirects
└── netlify.toml
```

See also the Hugo Docs: [Host on Netlify](https://gohugo.io/hosting-and-deployment/hosting-on-netlify/).

## Functions

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

See also the Netlify docs: [Functions overview](https://docs.netlify.com/functions/overview/)

## Redirects

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

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

See also the Netlify docs: [Redirects and rewrites](https://docs.netlify.com/routing/redirects/)

## Headers

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

```bash
/*
  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](https://docs.netlify.com/routing/headers/)

## Build and deploy

`./netlify.toml`:

```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](https://docs.netlify.com/configure-builds/file-based-configuration/)