- 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