Search
Search
Tutorial
Sign in to Sveltia CMS with GitHub through Netlify, and publish content on demand with a Netlify build hook.
Three services work together:
/admin/.Content is not published on every save. Editors save as often as they want, then click Publish Changes to rebuild the website.
| Step | How often |
|---|---|
| 1. Connect GitHub to Netlify | once per website |
| 2. Create the GitHub OAuth App | once for all your websites |
| 3. Add the OAuth App to Netlify | once per website |
| 4. Configure the CMS | once per website |
| 5. Create the Netlify build hook | once per website |
| 6. Sign in and add the build hook | once per editor and per browser |
| 7. Give editors access | once per editor |
skip_ci optionNetlify > Add new project > Import an existing project > GitHub
Pick the repository of the website, branch main, and click Deploy. The netlify.toml file of the project already holds the build command.
You only do this once: the same OAuth App serves all your websites hosted on Netlify, because its callback URL is always Netlify’s.
Open the form on your account, or on your organization (Organization > Settings > Developer settings > OAuth Apps > New OAuth App) so the app does not depend on a single person.
Register a new OAuth App| Field | Value |
|---|---|
| Application name | A generic name, e.g. Hugolify CMS. Editors see it on the GitHub authorization screen. |
| Homepage URL | Any URL, e.g. your own website. It is only displayed. |
| Authorization callback URL | https://api.netlify.com/auth/done |
| Enable Device Flow | Unchecked |
Click Register application, then Generate a new client secret. Copy the Client ID and the Client secret: the secret is displayed only once, so keep it in your password manager.
Create an OAuth App, not a GitHub App. If the form shows an Expire user access tokens checkbox, you are on the wrong one: the token would expire after 8 hours and editors would have to sign in again.
Project configuration > Access & security > OAuth
Under Authentication providers, click Install provider, choose GitHub, paste the Client ID and the Client secret from step 2, and click Install.
Repeat this step on every Netlify project, with the same Client ID and secret.
Regenerating the secret on GitHub means pasting it again on every Netlify project that uses it.
/config/_default/params.yaml
admin:
cms: sveltiacms
name: github
repo: owner/repo # your repository
skip_ci: true
auth:
netlify_identity: false
skip_ci: true adds [skip ci] to every commit made by the CMS, so Netlify does not build on each save. It is the default value.netlify_identity: false stops loading the Netlify Identity widget, which Sveltia CMS does not use.No base_url is needed: without one, Sveltia CMS uses Netlify as its OAuth server.
Commit and push. Netlify builds the website with the CMS on /admin/.
A build hook is a URL that starts a Netlify build when it is called. Sveltia CMS calls it when an editor clicks Publish Changes.
Project configuration > Build & deploy > Continuous deployment > Build hooks
Click Add build hook, name it Sveltia CMS, choose the main branch, save, then copy the URL. It looks like https://api.netlify.com/build_hooks/xxxxxxxx.
Anyone who knows this URL can start builds. Never commit it to the repository, and never put it in the CMS configuration, which is public.
https://your-website/admin/.The URL is stored in the browser, not in the repository: each editor pastes it once in their own browser. Send it to them over a secure channel.
If the repository belongs to a client’s GitHub organization that restricts third-party apps, an admin of that organization has to approve the OAuth App once.
| Action in the CMS | Result |
|---|---|
| Save | [skip ci] commit, the live website does not change |
| Publish Changes (in the header) | Calls the build hook: Netlify rebuilds the website with all saved content |
| Arrow next to Save > Save and Publish | Saves and publishes at once |
| Deleting an entry or a media file | Published right away: deletions are never marked [skip ci] |
A code push by a developer also triggers a build, and pending content goes live with it.
No GitHub sign-in is needed locally. Launch the project:
yarn watch
Open http://localhost:1313/admin/, click Work with Local Repository (Chrome or Edge) and select the project folder. Changes are written to the files without any commit: commit and push them yourself.
| Problem | Solution |
|---|---|
| Authentication Aborted on sign-in | A Cross-Origin-Opener-Policy header blocks the sign-in window. Set it to same-origin-allow-popups, or remove it. |
| Error or repository not found after sign-in | The GitHub account is not a collaborator of the repository, or has not accepted the invitation (step 7). |
| No Publish Changes button | Check skip_ci: true and the hugolify-admin version (v2.0.0-26 or later). |
| Publish Changes does not start a build | The build hook is not set in this browser (step 6). If the website has a CSP, allow https://api.netlify.com in connect-src. |
| The website does not change after Save | Expected with skip_ci: true: click Publish Changes. |
Table of contents
Table of contents