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.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 very 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_VERSION=0.7.0 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. With this setup, your site should be automatically deployed on every commit on master. For `ZOLA_VERSION`, you may
  14. use any of the tagged `release` versions in the GitHub repository — Netlify will automatically fetch the tagged version
  15. and use it to build your site.
  16. However, if you want to use everything that Netlify gives you, you should also publish temporary sites for pull requests.
  17. This is done by adding the following `netlify.toml` file in your repository and removing the build command/publish directory in
  18. the admin interface.
  19. ```toml
  20. [build]
  21. # assuming the Zola site is in a docs folder, if it isn't you don't need
  22. # to have a `base` variable but you do need the `publish` and `command`
  23. base = "docs"
  24. publish = "docs/public"
  25. command = "zola build"
  26. [build.environment]
  27. # Set the version name that you want to use and Netlify will automatically use it
  28. ZOLA_VERSION = "0.7.0"
  29. # The magic for deploying previews of branches
  30. # We need to override the base url with whatever url Netlify assigns to our
  31. # preview site. We do this using the Netlify environment variable
  32. # `$DEPLOY_PRIME_URL`.
  33. [context.deploy-preview]
  34. command = "zola build --base-url $DEPLOY_PRIME_URL"
  35. ```
  36. ## Manual Deploys
  37. If you would prefer to use a version of Zola that isn't a tagged release (for example, after having built Zola from
  38. source and made modifications), then you will need to manually deploy your `public` folder to Netlify. You can do this through
  39. Netlify's web GUI or via the command line.
  40. For a command-line manual deploy, follow these steps:
  41. 1. Generate a `Personal Access Token` from the settings section of your Netlify account (*not* an OAuth Application)
  42. 2. Build your site with `zola build`
  43. 3. Create a zip folder containing the `public` directory
  44. 4. Run the `curl` command below, filling in your values for PERSONAL_ACCESS_TOKEN_FROM_STEP_1, FILE_NAME.zip and SITE_NAME
  45. 5. (Optional) delete the zip folder
  46. ```bash
  47. curl -H "Content-Type: application/zip" \
  48. -H "Authorization: Bearer PERSONAL_ACCESS_TOKEN_FROM_STEP_1" \
  49. --data-binary "@FILE_NAME.zip" \
  50. https://api.netlify.com/api/v1/sites/SITE_NAME.netlify.com/deploys
  51. ```