- 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