Widgets

Widgets define the data type and interface for entry fields. Netlify CMS comes with several built-in widgets. Click the widget names in the sidebar to jump to specific widget details. We’re always adding new widgets, and you can also create your own!

Widgets are specified as collection fields in the Netlify CMS config.yml file. Note that YAML syntax allows lists and objects to be written in block or inline style, and the code samples below include a mix of both.

To see working examples of all of the built-in widgets, try making a ‘Kitchen Sink’ collection item on the CMS demo site. (No login required: click the login button and the CMS will open.) You can refer to the demo configuration code to see how each field was configured.

Image

Common widget options

The following options are available on all fields:

  • required: specify as false to make a field optional; defaults to true
  • hint: optionally add helper text directly below a widget. Useful for including instructions. Accepts markdown for bold, italic, strikethrough, and links.
  • pattern: add field validation by specifying a list with a regex pattern and an error message; more extensive validation can be achieved with custom widgets.
  • Example:
      label: "Title"
      name: "title"
      widget: "string"
      pattern: ['.{12,}', "Must have at least 12 characters"]

Default widgets

Boolean

The boolean widget translates a toggle switch input to a true/false value.

  • Name: boolean
  • UI: toggle switch
  • Data type: boolean
  • Options:
    • default: accepts true or false; defaults to false when required is set to false
  • Example:
    - {label: "Draft", name: "draft", widget: "boolean", default: true}

Code

The code widget provides a code editor (powered by Codemirror) with optional syntax awareness. Can output the raw code value or an object with the selected language and the raw code value.

  • Name: code
  • UI: code editor
  • Data type: string
  • Options:
    • default_language: optional; default language to use
    • allow_language_selection: optional; defaults to false: allows syntax to be changed
    • keys: optional; sets key names for code and lang if outputting an object; defaults to { code: 'code', lang: 'lang' }
    • output_code_only: set to true to output the string value only, defaults to false
  • Example:
    - label: 'Code'
    name: 'code'
    widget: 'code'

Image

Color

The color widget translates a color picker to a color string.

  • Name: color
  • UI: color picker
  • Data type: string
  • Options:
    • default: accepts a string; defaults to an empty string. Sets the default value
    • allowInput: accepts a boolean, defaults to false. Allows manual editing of the color input value
    • enableAlpha: accepts a boolean, defaults to false. Enables Alpha editing
  • Example:
    - { label: 'Color', name: 'color', widget: 'color' }
  • Example:
    - { label: 'Color', name: 'color', widget: 'color', enableAlpha: tru

Date

Deprecation notice: the date widget has been deprecated and will be removed in the next major release. Please use the datetime widget instead.

The date widget translates a date picker input to a date string. For saving date and time together, use the datetime widget.

  • Name: date
  • UI: date picker
  • Data type: Moment.js-formatted date string
  • Options:
    • default: accepts a date string, or an empty string to accept blank input; otherwise defaults to current date
    • format: optional; accepts Moment.js tokens; defaults to raw Date object (if supported by output format)
    • date_format: optional; boolean or Moment.js tokens. If true use default locale format.
    • time_format: optional; boolean or Moment.js tokens. If true use default locale format, false hides time-picker. Defaults to false.
  • Example:
    - label: 'Birthdate'
      name: 'birthdate'
      widget: 'date'
      default: ''
      format: 'MMM Do YY'

DateTime

The datetime widget translates a datetime picker to a datetime string.

  • Name: datetime
  • UI: datetime picker
  • Data type: Moment.js-formatted datetime string
  • Options:
    • default: accepts a datetime string, or an empty string to accept blank input; otherwise defaults to current datetime
    • format: sets storage format; accepts Moment.js tokens; defaults to raw Date object (if supported by output format)
    • date_format: sets date display format in UI; boolean or Moment.js tokens. If true use default locale format.
    • time_format: sets time display format in UI; boolean or Moment.js tokens. If true use default locale format, false hides time-picker.
    • picker_utc: (default: false) when set to true, the datetime picker will display times in UTC. When false, the datetime picker will display times in the user’s local timezone. When using date-only formats, it can be helpful to set this to true so users in all timezones will see the same date in the datetime picker.
  • Example:
    - label: "Start time"
      name: "start"
      widget: "datetime"
      default: ""
      date_format: "DD.MM.YYYY" # e.g. 24.12.2021
      time_format: "HH:mm" # e.g. 21:07
      format: "LLL"
      picker_utc: false

File

The file widget allows editors to upload a file or select an existing one from the media library. The path to the file will be saved to the field as a string.

  • Name: file
  • UI: file picker button opens media gallery
  • Data type: file path string
  • Options:
    • default: accepts a file path string; defaults to null
    • media_library: media library settings to apply when a media library is opened by the current widget
      • allow_multiple: (default: true) when set to false, prevents multiple selection for any media library extension, but must be supported by the extension in use
      • config: a configuration object that will be passed directly to the media library being used – available options are determined by the library
      • media_folder (Beta): file path where uploaded files will be saved specific to this control. Paths can be relative to a collection folder (e.g. files will add the file to a sub-folder in the collection folder) or absolute with reference to the base of the repo which needs to begin with / (e.g /static/files will save uploaded files to the static folder in a sub folder named files)
      • choose_url: (default: true) when set to false, the “Insert from URL” button will be hidden
  • Example:
    - label: "Manual PDF"
      name: "manual_pdf"
      widget: "file"
      default: "/uploads/general-manual.pdf"
      media_library:
        config:
          multiple: true

Hidden

Hidden widgets do not display in the UI. In folder collections that allow users to create new items, you will often want to set a default for hidden fields, so they will be set without requiring an input.

  • Name: hidden
  • UI: none
  • Data type: any valid data type
  • Options:
    • default: accepts any valid data type; recommended for collections that allow adding new items
  • Example:
    - {label: "Layout", name: "layout", widget: "hidden", default: "blog"

Image

The image widget allows editors to upload an image or select an existing one from the media library. The path to the image file will be saved to the field as a string.

  • Name: image
  • UI: file picker button opens media gallery allowing image files (jpg, jpeg, webp, gif, png, bmp, tiff, svg) only; displays selected image thumbnail
  • Data type: file path string
  • Options:
    • default: accepts a file path string; defaults to null
    • media_library: settings to apply when a media library is opened by the current widget
    • allow_multiple: (default: true) when set to false, multiple selection will be disabled even if the media library extension supports it
    • config: a configuration object passed directly to the media library; check the documentation of your media library extension for available config options
    • media_folder (Beta): file path where uploaded images will be saved specific to this control. Paths can be relative to a collection folder (e.g. images will add the image to a sub-folder in the collection folder) or absolute with reference to the base of the repo which needs to begin with / (e.g /static/images will save uploaded images to the static folder in a sub folder named images)
    • choose_url: (default: true) when set to false, the “Insert from URL” button will be hidden
  • Example:
  - label: "Featured Image"
    name: "thumbnail"
    widget: "image"
    choose_url: true
    default: "/uploads/chocolate-dogecoin.jpg"
    media_library:
      config:
        multiple: true

List

The list widget allows you to create a repeatable item in the UI which saves as a list of widget values. map a user-provided string with a comma delimiter into a list. You can choose any widget as a child of a list widget—even other lists.

  • Name: list
  • UI: without any fields specified, the list widget defaults to a text input for entering comma-separated values; with fields specified, the list widget contains a repeatable child widget, with controls for adding, deleting, and re-ordering the repeated widgets.
  • Data type: list of widget values
  • Options:
    • default: you may specify a list of strings to populate the basic text field, or an array of list items for lists using the fields option. If no default is declared when using field or fields, will default to a single list item using the defaults on the child widgets
    • allow_add: false hides the button to add additional items
    • collapsed: when true, the entries collapse by default
    • summary: specify the label displayed on collapsed entries
    • minimize_collapsed: when true, collapsing the list widget will hide all of it’s entries instead of showing summaries
    • label_singular: the text to show on the add button
    • field: a single widget field to be repeated
    • fields: a nested list of multiple widget fields to be included in each repeatable iteration
    • max: maximum number of items in the list
    • min: minimum number of items in the list
    • add_to_top: when true, new entries will be added to the top of the list
  • Example (field/fields not specified):
- label: "Tags"
  name: "tags"
  widget: "list"
  default: ["news"]
  • Example (allow_add marked false):
- label: "Tags"
  name: "tags"
  widget: "list"
  allow_add: false
  default: ["news"]
  • Example (with field):
- label: "Gallery"
  name: "galleryImages"
  widget: "list"
  summary: '{{fields.image}}'
  field: {label: Image, name: image, widget: image}
  • Example (with fields):
- label: "Testimonials"
  name: "testimonials"
  widget: "list"
  summary: '{{fields.quote}} - {{fields.author.name}}'
  fields:
    - {label: Quote, name: quote, widget: string, default: "Everything is awesome!"}
    - label: Author
      name: author
      widget: object
      fields:
        - {label: Name, name: name, widget: string, default: "Emmet"}
        - {label: Avatar, name: avatar, widget: image, default: "/img/emmet.jpg"}
  • Example (with default):
- label: "Gallery"
  name: "galleryImages"
  widget: "list"
  fields:
    - { label: "Source", name: "src", widget: "string" }
    - { label: "Alt Text", name: "alt", widget: "string" }
  default:
    - { src: "/img/tennis.jpg", alt: "Tennis" }
    - { src: "/img/footbar.jpg", alt: "Football" }
  • Example (collapsed marked false):
- label: "Testimonials"
  name: "testimonials"
  collapsed: false
  widget: "list"
  fields:
    - {label: Quote, name: quote, widget: string, default: "Everything is awesome!"}
    - {label: Author, name: author, widget: string }
  • Example (minimize_collapsed marked true):
- label: "Testimonials"
  name: "testimonials"
  minimize_collapsed: true
  widget: "list"
  fields:
    - {label: Quote, name: quote, widget: string, default: "Everything is awesome!"}
    - {label: Author, name: author, widget: string }
  • Example (with max & min):
- label: "Tags"
  name: "tags"
  widget: "list"
  max: 3
  min: 1
  default: ["news"]
  • Example (add_to_top marked true):
- label: "Tags"
  name: "tags"
  widget: "list"
  add_to_top: true

Map

The map widget allows you to edit spatial data using an interactive map. Spatial data for a single piece of geometry saves as a GeoJSON string in WGS84 projection.

  • Name: map
  • UI: interactive map
  • Data type: GeoJSON string
  • Options:
    • decimals: accepts a number to specify precision of saved coordinates; defaults to 7 decimals
    • default: accepts a GeoJSON string containing a single geometry; defaults to an empty string
    • type: accepts one string value of Point, LineString or Polygon; defaults to Point
  • Example:
    - {label: "Location", name: "location", widget: "map" }

Markdown

The markdown widget provides a full fledged text editor allowing users to format text with features such as headings and blockquotes. Users can change their editing view with a handy toggle button.

Please note: If you want to use your markdown editor to fill a markdown file contents after its frontmatter, you’ll have to name the field body so the CMS recognizes it and saves the file accordingly.

  • Name: markdown
  • UI: full text editor
  • Data type: markdown
  • Options:
    • default: accepts markdown content
    • minimal: accepts a boolean value, false by default. Sets the widget height to minimum possible.
    • buttons: an array of strings representing the formatting buttons to display (all shown by default). Buttons include: bold, italic, code, link, heading-one, heading-two, heading-three, heading-four, heading-five, heading-six, quote, bulleted-list, and numbered-list.
    • editor_components: an array of strings representing the names of editor components to display (all shown by default). Netlify CMS includes image and code-block editor components by default, and custom components may be created and registered.
    • modes: an array of strings representing the names of allowed editor modes. Possible modes are raw and rich_text. A toggle button appears in the toolbar when more than one mode is available.
    • sanitize_preview: accepts a boolean value, false by default. Sanitizes markdown preview to prevent XSS attacks – might alter the preview content.
  • Example:
    - { label: 'Blog post content', name: 'body', widget: 'markdown' }

This would render as:

Markdown widget example

Please note: The markdown widget outputs a raw markdown string. Your static site generator may or may not render the markdown to HTML automatically. Consult with your static site generator’s documentation for more information about rendering

Number

The number widget uses an HTML number input, saving the value as a string, integer, or floating point number.

  • Name: number
  • UI: HTML number input
  • Data type: string by default; configured by value_type option
  • Options:
    • default: accepts string or number value; defaults to empty string
    • value_type: accepts int or float; any other value results in saving as a string
    • min: accepts a number for minimum value accepted; unset by default
    • max: accepts a number for maximum value accepted; unset by default
    • step: accepts a number for stepping up/down values in the input; 1 by default
  • Example:
    - label: "Puppy Count"
      name: "puppies"
      widget: "number"
      default: 2
      value_type: "int"
      min: 1
      max: 101
      step: 2

markdown.

Object

The object widget allows you to group multiple widgets together, nested under a single field. You can choose any widget as a child of an object widget—even other objects.

  • Name: object
  • UI: a field containing one or more child widgets
  • Data type: list of child widget values
  • Options:
    • default: you can set defaults within each sub-field’s configuration
    • collapsed: if added and labeled true, collapse the widget’s content by default
    • summary: specify the label displayed when the object is collapsed
    • fields: (required) a nested list of widget fields to include in your widget
  • Example:
    - label: "Profile"
      name: "profile"
      widget: "object"
      summary: '{{fields.name}}: {{fields.birthdate}}'
      fields:
        - {label: "Public", name: "public", widget: "boolean", default: true}
        - {label: "Name", name: "name", widget: "string"}
        - label: "Birthdate"
          name: "birthdate"
          widget: "date"
          default: ""
          format: "MM/DD/YYYY"
        - label: "Address"
          name: "address"
          widget: "object"
          collapsed: true
          fields: 
            - {label: "Street Address", name: "street", widget: "string"}
            - {label: "City", name: "city", widget: "string"}
            - {label: "Postal Code", name: "post-code", widget: "string"

Relation

The relation widget allows you to reference items from another collection. It provides a search input with a list of entries from the collection you’re referencing, and the list automatically updates with matched entries based on what you’ve typed.

  • Name: relation
  • UI: text input with search result dropdown
  • Data type: data type of the value pulled from the related collection item
  • Options:
    • collection: (required) name of the referenced collection (string)
    • value_field: (required) name of the field from the referenced collection whose value will be stored for the relation. For nested fields, separate each subfield with a . (e.g. name.first). For list fields use a wildcard * to target all list items (e.g. categories.*).
    • search_fields: (required) list of one or more names of fields in the referenced collection to search for the typed value. Syntax to reference nested fields is similar to that of value_field.
    • file: allows referencing a specific file when the referenced collection is a files collection (string)
    • display_fields: list of one or more names of fields in the referenced collection that will render in the autocomplete menu of the control. Defaults to value_field. Syntax to reference nested fields is similar to that of value_field.
    • default: accepts any widget data type; defaults to an empty string
    • multiple : accepts a boolean, defaults to false
    • min: minimum number of items; ignored if multiple is false
    • max: maximum number of items; ignored if multiple is false
    • options_length: accepts integer to override number of options presented to user. Defaults to 20.
  • Referencing a folder collection example (assuming a separate “authors” collection with “name” and “twitterHandle” fields with subfields “first” and “last” for the “name” field):
- label: "Post Author"
  name: "author"
  widget: "relation"
  collection: "authors"
  search_fields: ["name.first", "twitterHandle"]
  value_field: "name.first"
  display_fields: ["twitterHandle", "followerCount"]

The generated UI input will search the authors collection by name and twitterHandle, and display each author’s handle and follower count. On selection, the author’s name is saved for the field.

  • String templates example (assuming a separate “authors” collection with “name” and “twitterHandle” fields with subfields “first” and “last” for the “name” field):
- label: "Post Author"
  name: "author"
  widget: "relation"
  collection: "authors"
  search_fields: ['name.first']
  value_field: "{{slug}}"
  display_fields: ["{{twitterHandle}} - {{followerCount}}"]

The generated UI input will search the authors collection by name, and display each author’s handle and follower count. On selection, the author entry slug is saved for the field.

  • Referencing a file collection list field example (assuming a separate “relation_files” collection with a file named “cities” with a list field “cities” with subfields “name” and “id”):
- label: "City"
  name: "city"
  widget: "relation"
  collection: "relation_files"
  file: "cities"
  search_fields: ["cities.*.name"]
  display_fields: ["cities.*.name"]
  value_field: "cities.*.id"

The generated UI input will search the cities file by city name, and display each city’s name. On selection, the city id is saved for the field.

Select

The select widget allows you to pick a string value from a dropdown menu.

  • Name: select
  • UI: select input
  • Data type: string or array
  • Options:
    • default: options must contain any default values
      • string values: accepts a string; defaults to an empty string. Accepts an array of strings and defaults to an empty array with multiple: true enabled.
      • object with label and value fields: accepts an object with label and value field or an array of such objects when multiple: true is enable. Defaults to no value
    • options: (required) there are two ways to list of options for the dropdown menu:
      • string values: the dropdown displays the value directly
      • object with label and value fields: the label displays in the dropdown; the value saves in the file
    • multiple: accepts a boolean; defaults to false
    • min: minimum number of items; ignored if multiple is false
    • max: maximum number of items; ignored if multiple is false
  • Example (options as strings):
- label: "Align Content"
  name: "align"
  widget: "select"
  options: ["left", "center", "right"]

Selecting the center option, will save the value as:

align: "center"
  • Example (options as objects):
- label: "City"
  name: "airport-code"
  widget: "select"
  options:
    - { label: "Chicago", value: "ORD" }
    - { label: "Paris", value: "CDG" }
    - { label: "Tokyo", value: "HND" }

Selecting the Chicago option, will save the value as:

airport-code: "ORD"
  • Example (multiple):
- label: "Tags"
  name: "tags"
  widget: "select"
  multiple: true
  options: ["Design", "UX", "Dev"]
  default: ["Design"]
  • Example (min/max):
- label: "Tags"
  name: "tags"
  widget: "select"
  multiple: true
  min: 1
  max: 3
  options: ["Design", "UX", "Dev"]
  default: ["Design"]

String

The string widget translates a basic text input to a string value. For larger textarea inputs, use the text widget.

  • Name: string
  • UI: text input
  • Data type: string
  • Options:
    • default: accepts a string; defaults to an empty string
  • Example:
    - {label: "Title", name: "title", widget: "string"}

Text

The text widget takes a multiline text field and saves it as a string. For shorter text inputs, use the string widget.

  • Name: text
  • UI: HTML textarea
  • Data type: string
  • Options:
    • default: accepts a string; defaults to an empty string
  • Example:
    - {label: "Description", name: "description", widget: "text"}

 

Authentication Providers

Authentication Providers

One challenge for frontend projects is handling authentication. OAuth2 is a widely accepted standard used by many services and APIs, but the OAuth authentication process requires a server to send a signed request to the OAuth server, signed with a secret that you can never expose to the client side of your application.

Netlify solves this problem by providing an integrated service that will sign the OAuth requests for you and give back an access token ready to use.

Netlify currently supports authentication with GitHub, GitLab, and Bitbucket.

#Enable OAuth for a Netlify site

While the below workflow is specifically for GitHub, the GitLab and Bitbucket workflows are similar.

Before you can use an authentication provider, you need to:

  1. register an API application with the OAuth provider
  2. configure credentials in the Netlify UI

#OAuth provider setup

You need to create an API application and make note of the Client ID and a Client Secret so that you can use them in your Netlify configuration.

  1. In GitHub, go to your account Settings and select Developer Settings, then OAuth Apps or use this shortcut.
  2. Select Register a new application.
  3. For the Authorization callback URL, enter https://web.archive.org/web/20220805155937/https://api.netlify.com/auth/done. The other fields can contain anything you want.Image
  4. On your new application’s GitHub overview page, make note of the Client ID.
  5. Generate a Client Secret and make note of it for later. You can’t access this secret again.

#Netlify UI settings

When you complete application registration with GitHub, you need to add the Client ID and Client Secret to your Netlify site:

  1. Go to Site settings > Access control > OAuth.
  2. Under Authentication Providers, select Install Provider.
  3. Select GitHub and enter the Client ID and Client Secret from earlier, then save.

#Site usage example

Once you’ve configured an authentication provider, you can use it to obtain an access token in your application.

You can preview the OAuth user experience in our demo.

Here’s an example of how to ask users to authenticate with GitHub and use the resulting token in your application’s calls to the GitHub API:

<!DOCTYPE html>
<html>
  <head>
    <title>GitHub Authentication Example</title>

    <!-- Make sure to include Netlify’s authentication library -->
    <!-- Also available from npm as netlify-auth-providers -->
    <script src="https://web.archive.org/web/20220805155937/https://unpkg.com/netlify-auth-providers"></script>
  </head>
  <body>
    <h1>GitHub Authentication Example:</h1>
    <p><a href="#" id="login">Authenticate</a></p>
    <p>Token: <span id="output-token">Not authenticated yet</span></p>
    <p>
      User emails:
      <span id="output-email">Not authenticated yet</span>
    </p>

    <script>
      const anchorTag = document.getElementById("login");
      const outputToken = document.getElementById("output-token");
      const outputEmail = document.getElementById("output-email");

      anchorTag.addEventListener("click", (event) => {
        event.preventDefault();

        const authenticator = new netlify.default({});

        authenticator.authenticate(
          // Set the OAuth provider and token scope
          // Provider can be "github", "gitlab", or "bitbucket"
          // The scopes available depend on your OAuth provider
          { provider: "github", scope: "user" },
          async function (error, data) {
            if (error) {
              outputToken.innerText =
                "Error Authenticating with GitHub: " + error;
            } else {
              outputToken.innerText =
                "Authenticated with GitHub. Access Token: " +
                data.token;
              outputEmail.innerText = await loadGitHubUserEmails(
                data.token
              );
            }
          }
        );
      });

      async function loadGitHubUserEmails(token) {
        return await fetch("https://web.archive.org/web/20220805155937/https://api.github.com/user/emails", {
          headers: {
            Accept: "application/vnd.github.v3+json",
            Authorization: `token ${token}`,
          },
        })
          .then((response) => response.json())
          .then((response) => JSON.stringify(response));
      }
    </script>
  </body>
</html> OAuth tokens are scoped to limit access. Each OAuth provider has different scopes you can use in your application. In the above GitHub example, the scope is set to user, which has read and write access to profile information. If you don’t provide a scope, OAuth providers usually apply the default scope to your token. Default scopes typically only have read access to public information. You can find a list of scopes for supported OAuth providers below: GitHub GitLab Bitbucket

GitLab Backend

GitLab

For repositories stored on GitLab, the gitlab backend allows CMS users to log in directly with their GitLab account. Note that all users must have push access to your content repository for this to work.

Note: GitLab default branch is protected by default, thus typically requires maintainer permissions in order for users to have push access.

The GitLab API allows for two types of OAuth2 flows:

  • Web Application Flow, which works much like the GitHub OAuth flow described above.
  • Implicit Grant, which operates without the need for an authentication server.

Web Application Flow with Netlify

When using GitLab’s Web Application Flow for authentication, you can use Netlify to handle the server-side authentication requests.

To enable it:

  1. Follow the GitLab docs to add your Netlify CMS instance as an OAuth application. For the Redirect URI, enter https://api.netlify.com/auth/done, and check the box for api scope.
  2. Follow the Netlify docs to add your new GitLab Application ID and Secret to your Netlify site dashboard.
  3. In your repository, add the following lines to your Netlify CMS config.yml file:
backend:
  name: gitlab
  repo: owner-name/repo-name # Path to your GitLab repository

Client-Side Implicit Grant (GitLab)

With GitLab’s Implicit Grant, users can authenticate with GitLab directly from the client. To do this:

  1. Follow the GitLab docs to add your Netlify CMS instance as an OAuth application. For the Redirect URI, enter the address where you access Netlify CMS, for example, https://www.mysite.com/admin/. For scope, select api.
  2. GitLab gives you an Application ID. Copy this ID and enter it in your Netlify CMS config.yml file, along with the following settings:
    backend:
     name: gitlab
     repo: owner-name/repo-name # Path to your GitLab repository
     auth_type: implicit # Required for implicit grant
     app_id: your-app-id # Application ID from your GitLab settings

    You can also use Implicit Grant with a self-hosted GitLab instance. This requires adding api_rootbase_url, and auth_endpoint fields:

    backend:
     name: gitlab
     repo: owner-name/repo-name # Path to your GitLab repository
     auth_type: implicit # Required for implicit grant
     app_id: your-app-id # Application ID from your GitLab settings
     api_root: https://my-hosted-gitlab-instance.com/api/v4
     base_url: https://my-hosted-gitlab-instance.com
     auth_endpoint: oauth/authorize

Note: In both cases, GitLab also provides you with a client secret. You should never store this in your repo or reveal it in the client.

Test Backend

Test

You can use the test-repo backend to try out Netlify CMS without connecting to a Git repo. With this backend, you can write and publish content normally, but any changes will disappear when you reload the page. This backend powers the Netlify CMS demo site.

Image

Note: The test-repo backend can’t access your local file system, nor does it connect to a Git repo, thus you won’t see any existing files while using it.

To enable this backend, add the following lines to your Netlify CMS config.yml file:

backend:
  name: test-repo

Git Gateway

Git Gateway is a Netlify open source project that allows you to add editors to your site CMS without giving them direct write access to your GitHub or GitLab repository. (For Bitbucket repositories, use the Bitbucket backend instead.)

Git Gateway with Netlify

The Netlify Identity service can handle the authentication and provides a simple interface for user management. The Netlify CMS featured templates are working examples of this backend.

To use it in your own project stored on GitHub or GitLab, follow these steps:

  1. Head over to the Netlify Identity docs and follow the steps to get started.
  2. Add the following lines to your Netlify CMS config.yml file:
backend:
  name: git-gateway

Reconnect after Changing Repository Permissions

If you change ownership on your repository, or convert a repository from public to private, you may need to reconnect Git Gateway with proper permissions. Find further instructions in the Netlify Git Gateway docs.

Git Gateway without Netlify

You can use Git Gateway without Netlify by setting up your own Git Gateway server and connecting it with your own instance of GoTrue (the open source microservice that powers Netlify Identity), or with any other identity service that can issue JSON Web Tokens (JWT).

To configure in Netlify CMS, use the same backend settings in your Netlify CMS config.yml file as described in Step 2 of the Git Gateway with Netlify Identity instructions above.

Netlify Large Media

Netlify Large Media is a Git LFS implementation for repositories connected to Netlify sites. This means that you can use Git to work with large asset files like images, audio, and video, without bloating your repository. It does this by replacing the asset files in your repository with text pointer files, then uploading the assets to the Netlify Large Media storage service.

If you have a Netlify site with Large Media enabled, Netlify CMS (version 2.6.0 and above) will handle Large Media asset files seamlessly, in the same way as files stored directly in the repository.

Requirements

To use Netlify Large Media with Netlify CMS, you will need to do the following:

When these are complete, you can use Netlify CMS as normal, and the configured asset files will automatically be handled by Netlify Large Media.

Image transformations

All JPEG, PNG, and GIF files that are handled with Netlify Large Media also have access to Netlify’s on-demand image transformation service. This service allows you to request an image to match the dimensions you specify in a query parameter added to the image URL.

You can learn more about this feature in Netlify’s image transformation docs.

In repositories enabled with Netlify Large Media, Netlify CMS will use the image transformation query parameters to load thumbnail-sized images for the media gallery view. This makes images in the media gallery load significantly faster.

Note: When using this option all tracked file types have to be imported into Large Media. For example if you track *.jpg but still have jpg-files that are not imported into Large Media the backend will throw an error. Check the netlify docs on how to add previously committed files to Large Media.

You can disable the automatic image transformations with the use_large_media_transforms_in_media_library configuration setting, nested under backend in the CMS config.yml file:

backend:
  name: git-gateway
  ## Set to false to prevent transforming images in media gallery view
  use_large_media_transforms_in_media_library: false