You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

netlify.md 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. +++
  2. title = "Netlify"
  3. weight = 20
  4. +++
  5. Netlify provides best practices like SSL, CDN distribution, caching and continuous deployment
  6. with no effort. This site is hosted by Netlify and automatically deployed on commits.
  7. If you don't have an account with Netlify, you can [sign up](https://app.netlify.com) for one.
  8. ## Automatic deploys
  9. Once you are in the admin interface, you can add a site from a Git provider (GitHub, GitLab or Bitbucket). At the end
  10. of this process, you can select the deploy settings for the project:
  11. - build command: `zola build` (replace the version number in the variable by the version you want to use)
  12. - publish directory: the path to where the `public` directory is
  13. - image selection: `Ubuntu Xenial 16.04 (default)`
  14. - Environment variables: `ZOLA_VERSION` with for example `0.8.0` as value
  15. With this setup, your site should be automatically deployed on every commit on master. For `ZOLA_VERSION`, you may
  16. use any of the tagged `release` versions in the GitHub repository. Netlify will automatically fetch the tagged version
  17. and use it to build your site.
  18. However, if you want to use everything that Netlify gives you, you should also publish temporary sites for pull requests.
  19. This is done by adding the following `netlify.toml` file in your repository and removing the build command/publish
  20. directory in the admin interface.
  21. ```toml
  22. [build]
  23. # This assumes that the Zola site is in a docs folder. If it isn't, you don't need
  24. # to have a `base` variable but you do need the `publish` and `command` variables.
  25. base = "docs"
  26. publish = "docs/public"
  27. command = "zola build"
  28. [build.environment]
  29. # Set the version name that you want to use and Netlify will automatically use it.
  30. ZOLA_VERSION = "0.9.0"
  31. # The magic for deploying previews of branches.
  32. # We need to override the base url with whatever url Netlify assigns to our
  33. # preview site. We do this using the Netlify environment variable
  34. # `$DEPLOY_PRIME_URL`.
  35. [context.deploy-preview]
  36. command = "zola build --base-url $DEPLOY_PRIME_URL"
  37. ```
  38. ## Manual deploys
  39. If you would prefer to use a version of Zola that isn't a tagged release (for example, after having built Zola from
  40. source and made modifications), then you will need to manually deploy your `public` folder to Netlify. You can do
  41. this through Netlify's web GUI or via the command line.
  42. For a command-line manual deploy, follow these steps:
  43. 1. Generate a `Personal Access Token` from the settings section of your Netlify account (*not* an OAuth Application).
  44. 2. Build your site with `zola build`.
  45. 3. Create a zip folder containing the `public` directory.
  46. 4. Run the `curl` command below, filling in your values for PERSONAL_ACCESS_TOKEN_FROM_STEP_1, FILE_NAME.zip
  47. and SITE_NAME.
  48. 5. (Optional) delete the zip folder.
  49. ```bash
  50. curl -H "Content-Type: application/zip" \
  51. -H "Authorization: Bearer PERSONAL_ACCESS_TOKEN_FROM_STEP_1" \
  52. --data-binary "@FILE_NAME.zip" \
  53. https://api.netlify.com/api/v1/sites/SITE_NAME.netlify.com/deploys
  54. ```