- netlify实际是个ci(continious integration)工作,他可以把你的代码从服务器上github取下来然后执行hugo命令生成html到public(或者其他目录),然后自动绑定一个域名,比如https://gracious-swanson-416e03.netlify.com
1. netlify部署很简单,首先要做你的config.toml所在目录下创建一个netlify.toml
```
[build]
publish = "public"
command = "hugo --gc --minify"
[context.production.environment]
HUGO_VERSION = "0.60.1"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
[context.split1]
command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment]
HUGO_VERSION = "0.60.1"
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.deploy-preview.environment]
HUGO_VERSION = "0.60.1"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.branch-deploy.environment]
HUGO_VERSION = "0.60.1"
[context.next.environment]
HUGO_ENABLEGITINFO = "true"
```
2. 注册netlify,最好使用github账户的授权登录,deploy setting repository:github.com/clouda3/gohugo.me,base direcotry:gohugo.me,build command:hugo ,public directory gohugo.me/public
3. trigger deploy,Deploy log
```
9:42:04 AM: Build ready to start
9:42:10 AM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
9:42:10 AM: build-image tag: v3.3.5
9:42:10 AM: buildbot version: eb060c4dc3a8a73f9004f460f04632708166ca51
9:42:10 AM: Fetching cached dependencies
9:42:10 AM: Starting to download cache of 81.8MB
9:42:10 AM: Finished downloading cache in 539.546368ms
9:42:10 AM: Starting to extract cache
9:42:13 AM: Finished extracting cache in 2.36787649s
9:42:13 AM: Finished fetching cache in 2.942032835s
9:42:13 AM: Starting to prepare the repo for build
9:42:13 AM: Preparing Git Reference refs/heads/master
9:42:14 AM: Found Netlify configuration file. Overriding site configuration
9:42:14 AM: Found Netlify configuration file in base directory: gohugo.me. Overriding existing configuration
9:42:14 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify' versus 'hugo' in the Netlify UI
9:42:14 AM: Starting build script
9:42:14 AM: Installing dependencies
9:42:14 AM: Started restoring cached node version
9:42:16 AM: Finished restoring cached node version
9:42:17 AM: v10.17.0 is already installed.
9:42:17 AM: Now using node v10.17.0 (npm v6.11.3)
9:42:18 AM: Attempting ruby version 2.6.2, read from environment
9:42:19 AM: Using ruby version 2.6.2
9:42:19 AM: Using PHP version 5.6
9:42:19 AM: Installing Hugo 0.60.1
9:42:19 AM: Hugo Static Site Generator v0.60.1-96066756/extended linux/amd64 BuildDate: 2019-11-29T15:03:40Z
9:42:19 AM: Started restoring cached go cache
9:42:19 AM: Finished restoring cached go cache
9:42:19 AM: unset GOOS;
9:42:19 AM: unset GOARCH;
9:42:19 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
9:42:19 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
9:42:19 AM: go version >&2;
9:42:19 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
9:42:20 AM: go version go1.12 linux/amd64
9:42:20 AM: Installing missing commands
9:42:20 AM: Verify run directory
9:42:20 AM: Executing user command: hugo --gc --minify
9:42:20 AM: Building sites …
9:42:20 AM: |
9:42:20 AM: EN
9:42:20 AM: +------------------+----+
9:42:20 AM: Pages | 48
9:42:20 AM: Paginator pages | 6
9:42:20 AM: Non-page files | 0
9:42:20 AM: Static files | 7
9:42:20 AM: Processed images |
9:42:20 AM: 0
9:42:20 AM: Aliases | 11
9:42:20 AM: Sitemaps | 1
9:42:20 AM: Cleaned | 0
9:42:20 AM: Total in 139 ms
9:42:20 AM: Skipping functions preparation step: no functions directory set
9:42:20 AM: Caching artifacts
9:42:20 AM: Started saving pip cache
9:42:20 AM: Finished saving pip cache
9:42:20 AM: Started saving emacs cask dependencies
9:42:20 AM: Finished saving emacs cask dependencies
9:42:20 AM: Started saving maven dependencies
9:42:20 AM: Finished saving maven dependencies
9:42:20 AM: Started saving boot dependencies
9:42:20 AM: Finished saving boot dependencies
9:42:20 AM: Started saving go dependencies
9:42:20 AM: Finished saving go dependencies
9:42:20 AM: Build script success
9:42:20 AM: Starting to deploy site from 'gohugo.me/public'
9:42:20 AM: Creating deploy tree
9:42:20 AM: 0 new files to upload
9:42:20 AM: 0 new functions to upload
9:42:20 AM: Starting post processing
9:42:22 AM: Post processing done
9:42:22 AM: Site is live
```
4. Domain management 更改subdomain name:gohugome.netlify.com 访问:https://gohugome.netlify.com/
5. AWS route53 www.gohugo.me cname https://gohugome.netlify.com
- 【入门】1:Hugo介绍
- 【入门】2:Hugo网站和主题演示
- 【入门】3:Hugo跟Wordpress和Hexo对比
- 【入门】4:20分钟快速搭建Hugo网站
- 【入门】5:免费网站托管到Gitpages
- 【入门】6:图标icon/robot.txt/404页面创建和设置
- 【入门】7:网站地图sitemap
- 【进阶】8:自定义菜单
- 【进阶】9:自定义Tag/category
- 【进阶】10:页面Meta keyword
- 【进阶】12:创建页面摘要
- 【进阶】11:创建列表【进行中...】
- 【进阶】13:创建分页
- 【进阶】14:创建统计
- 【进阶】15:创建rss
- 【高级】16:创建页面目录
- 【高级】17:创建站内搜索
- 【高级】18:创建多语言支持
- 【高级】19:显示相关内容
- 【高级】20:显示当前页面所有Tag
- 【高级】21:创建社交联系方式
- 【高级】22:创建社交分享
- 【高级】23:创建评论gitalk
- 【高级】24:自动化部署-netlify
- 【高级】25:自动化部署-Github actions