Skip to content

Instantly share code, notes, and snippets.

@ashx3s
Last active November 15, 2021 18:48
Show Gist options
  • Select an option

  • Save ashx3s/94398c49afce55e49032251687227cfc to your computer and use it in GitHub Desktop.

Select an option

Save ashx3s/94398c49afce55e49032251687227cfc to your computer and use it in GitHub Desktop.
Netlify CMS Setup

Netlify CMS Setup

Everything in this gist is taken from netlify's docs on setting up nuxt with netlify cms. This is an abbreviated version. I recommend reading through the docs page as well.

  • In the static/ directory of your nuxt install, add a folder called admin/
  • inside admin create 2 files
    • index.html
    • config.yml

Index.html (Admin UI Page)

  • Paste this code into the index.html file
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Content Manager</title>
    <!-- Include the script that enables Netlify Identity on this page. -->
    <script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
  </head>
  <body>
    <!-- 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>

Config.yml

  • In your config.yml file, add this starter code
backend:
  name: git-gateway
  branch: main # Branch to update (optional; defaults to master)

media_folder: static/img
public_folder: /img

collections:
  - name: 'blog'
    label: 'Blog'
    folder: 'content/blog'
    format: 'frontmatter'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    editor:
      preview: false
    fields:
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Description', name: 'description', widget: 'string' }
      - { label: 'Body', name: 'body', widget: 'markdown' }

index.vue

Add the authentication widgit to your index page

  head() {
    return {
      script: [{ src: 'https://identity.netlify.com/v1/netlify-identity-widget.js' }],
    };
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment