Skip to content

Instantly share code, notes, and snippets.

@tech4him1
Last active March 30, 2023 13:41
Show Gist options
  • Save tech4him1/52a2b125fb555ecdb162b21a1ccdb395 to your computer and use it in GitHub Desktop.
Save tech4him1/52a2b125fb555ecdb162b21a1ccdb395 to your computer and use it in GitHub Desktop.
Netlify CMS w/ Git Gateway on external hosting.

Using Netlify's hosted Identity and Git Gateway service with Netlify CMS when hosted on a separate service.

CMS config.yml changes

The backend section of your config should contain the following three keys. Replace www.my-netlify-site.com with your Netlify site URL.

backend:
  name: git-gateway
  identity_url: "https://www.my-netlify-site.com/.netlify/identity"
  gateway_url: "https://www.my-netlify-site.com/.netlify/git"

CMS index.html changes

Assuming you already have the Netlify Identity script added (netlify-identity-widget.js), use the script netlify-identity.js instead.

  <script src="https://identity.netlify.com/v1/netlify-identity.js"></script>

Next, add this script to your <body>, but make sure it is before the CMS script. Again, replace www.my-netlify-site.com with your Netlify site URL.

  <script>
    netlifyIdentity.init({
      APIUrl: "https://www.my-netlify-site.com/.netlify/identity"
    });
  </script>
backend:
name: git-gateway
identity_url: "https://www.my-netlify-site.com/.netlify/identity"
gateway_url: "https://www.my-netlify-site.com/.netlify/git"
...
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>
<script src="https://identity.netlify.com/v1/netlify-identity.js"></script>
</head>
<body>
<script>
netlifyIdentity.init({
APIUrl: "https://www.my-netlify-site.com/.netlify/identity"
});
</script>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment