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 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. Netlify has built-in support for the older version (named Gutenberg) but not for Zola yet.
  9. ## Automatic Deploys (*Gutenberg only*)
  10. > Automatic deploys based on environment variable are not available for Zola yet,
  11. > only for version <= 0.4.2 when it was called Gutenberg
  12. Once you are in the admin interface, you can add a site from a Git provider (GitHub, GitLab or Bitbucket). At the end
  13. of this process, you can select the deploy settings for the project:
  14. - build command: `GUTENBERG_VERSION=0.4.2 gutenberg build` (replace the version number in the variable by the version you want to use)
  15. - publish directory: the path to where the `public` directory is
  16. With this setup, your site should be automatically deployed on every commit on master. For `GUTENBERG_VERSION`, you may
  17. use any of the tagged `release` versions in the GitHub repository — Netlify will automatically fetch the tagged version
  18. and use it to build your site.
  19. However, if you want to use everything that Netlify gives you, you should also publish temporary sites for pull requests.
  20. This is done by adding the following `netlify.toml` file in your repository and removing the build command/publish directory in
  21. the admin interface.
  22. ```toml
  23. [build]
  24. # assuming the Gutenberg site is in a docs folder, if it isn't you don't need
  25. # to have a `base` variable but you do need the `publish` and `command`
  26. base = "docs"
  27. publish = "docs/public"
  28. command = "gutenberg build"
  29. [build.environment]
  30. # Set the version name that you want to use and Netlify will automatically use it
  31. GUTENBERG_VERSION = "0.5.0"
  32. # The magic for deploying previews of branches
  33. # We need to override the base url with whatever url Netlify assigns to our
  34. # preview site. We do this using the Netlify environment variable
  35. # `$DEPLOY_PRIME_URL`.
  36. [context.deploy-preview]
  37. command = "gutenberg build --base-url $DEPLOY_PRIME_URL"
  38. ```
  39. ## Automatic deploys for Zola
  40. Since Netlify doesn't support Zola currently, you will need to download the archive directly from GitHub, replacing the version in the URL with the one you want:
  41. ```
  42. command = "curl -sL https://github.com/getzola/zola/releases/download/v0.7.0/zola-v0.7.0-x86_64-unknown-linux-gnu.tar.gz | tar zxv && ./zola build"
  43. ```
  44. ## Manual Deploys
  45. If you would prefer to use a version of Zola that isn't a tagged release (for example, after having built Zola from
  46. source and made modifications), then you will need to manually deploy your `public` folder to Netlify. You can do this through
  47. Netlify's web GUI or via the command line.
  48. For a command-line manual deploy, follow these steps:
  49. 1. Generate a `Personal Access Token` from the settings section of your Netlify account (*not* an OAuth Application)
  50. 2. Build your site with `zola build`
  51. 3. Create a zip folder containing the `public` directory
  52. 4. Run the `curl` command below, filling in your values for PERSONAL_ACCESS_TOKEN_FROM_STEP_1, FILE_NAME.zip and SITE_NAME
  53. 5. (Optional) delete the zip folder
  54. ```bash
  55. curl -H "Content-Type: application/zip" \
  56. -H "Authorization: Bearer PERSONAL_ACCESS_TOKEN_FROM_STEP_1" \
  57. --data-binary "@FILE_NAME.zip" \
  58. https://api.netlify.com/api/v1/sites/SITE_NAME.netlify.com/deploys
  59. ```