GATSBY
Last updated
Last updated
This guide will help you get started using Netlify CMS and Gatsby.
To get up and running with Gatsby, you’ll need to have installed on your computer. Note: Gatsby's minimum supported Node.js version is Node 8.
Let's create a new site using the default Gatsby Starter Blog. Run the following commands in the terminal, in the folder where you'd like to create the blog:
In your favorite code editor, open up the code generated for your "Gatsby Starter Blog" site, and take a look at the content
directory.
You will see that there are multiple Markdown files that represent blog posts. Open one .md
file and you will see something like this:
We can see above that each blog post has a title, a date, a description and a body. Now, let's recreate this using Netlify CMS.
First let's install some dependencies. We'll need netlify-cms-app
and gatsby-plugin-netlify-cms
. Run the following command in the terminal at the root of your site:
For the purpose of this guide we will deploy to Netlify from a GitHub repository which requires the minimum configuration.
Create a config.yml
file in the directory structure you see below:
In your config.yml
file paste the following configuration:
Note: The above configuration allows assets to be stored relative to their content. Therefore posts would be stored in the format below as it is in gatsby-starter-blog
.
Finally, add the plugin to your gatsby-config.js
.
It's now time to commit your changes and push to GitHub. The Gatsby starter initializes Git automatically for you, so you only need to do:
Go to Netlify and select 'New Site from Git'. Select GitHub and the repository you just pushed to. Click Configure Netlify on GitHub and give access to your repository. Finish the setup by clicking Deploy Site. Netlify will begin reading your repository and starting building your project.
Netlify's Identity and Git Gateway services allow you to manage CMS admin users for your site without requiring them to have an account with your Git host or commit access on your repo. From your site dashboard on Netlify:
Go to Settings > Identity, and select Enable Identity service.
Under Registration preferences, select Open or Invite only. In most cases, you want only invited users to access your CMS, but if you're just experimenting, you can leave it open for convenience.
If you'd like to allow one-click login with services like Google and GitHub, check the boxes next to the services you'd like to use, under External providers.
It's time to create your first blog post. Login to your site's /admin/
page and create a new post by clicking New Blog. Add a title, a date and some text. When you click Publish, a new commit will be created in your GitHub repo with this format Create Blog “year-month-date-title”
.
Then Netlify will detect that there was a commit in your repo, and will start rebuilding your project. When your project is deployed you'll be able to see the post you created.
It is now safe to remove the default Gatsby blog posts.
The Gatsby team is passionate about helping you create websites that work for everyone, with helpful defaults that bake in web accessibility as well as performance optimizations. By making your website accessible to people with disabilities, you can make more inclusive sites that reach and remove barriers for more people on the Internet.
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
The web of today is an important resource in many aspects of life such as health care, education, or commerce. Accessibility is an important consideration when building for the web.
While ultimately it’s up to you to develop your site with accessibility in mind, Gatsby aims to provide as much out-of-the-box support as possible.
One of the most common features of every site is navigation. People should be able to navigate across your pages and content in an intuitive and accessible way.
Accessibility by default is a win for everyone. Here’s a starting point for accessibility testing when making a Gatsby site or theme:
Scroll down to Services > Git Gateway, and click Enable Git Gateway. This authenticates with your Git host and generates an API access token. In this case, we're leaving the Roles field blank, which means any logged in user may access the CMS. For information on changing this, check the .
means that websites, tools, and technologies are designed and developed so that people with disabilities can use them. But not only people with permanent disabilities benefit from it. Accessibility also benefits people with temporary disabilities. For example, imagine being in an environment where you cannot listen to audio or you can’t use a computer because of a broken arm.
Back in the early days of the Web, Tim Berners-Lee, inventor of the World Wide Web, :
Accessibility supports , and has a strong .
That’s why every Gatsby site aims to have an accessible navigation experience by default. Thanks to , a routing library for React, Gatsby handles page announcements for screen readers on page change. We’re actively making improvements to this experience, and we .
Since the , your Gatsby sites use @reach/router
under the hood. While additional accessibility testing is always a good idea, the wraps to improve accessibility without you having to think about it. @reach/router
also supports .
For websites, rendering pages means that JavaScript isn’t required to access and navigate through content. Gatsby HTML pages by default from React components using , meaning you don’t have to worry about setting up server-rendering yourself to support . With Gatsby’s static support out of the box, you can build dynamic sites that still enable user access without requiring scripting.
Gatsby ships with the eslint-plugin-jsx-a11y
package and warnings for all of its rules enabled by default. is an accessibility tool for your code, helping you develop more inclusive Gatsby projects by reducing the time to find accessibility errors. This plugin encourages you to include alternative text for image tags, validates props, and eliminates redundant role properties, among other things.
For more on supported rules, check out the docs for . You can customize those rules in your ..eslintrc
Note: Including a local .eslintrc
file will all of Gatsby’s default linting and disable the built-in eslint-loader
, meaning your tweaked rules won’t make it to your browser’s developer console or your terminal window but will still be displayed if you have ESLint plugins enabled in your IDE. If you would like to change this behavior and make sure the eslint-loader
pulls in your customizations, you’ll need to enable the loader yourself. One way to do this is by using the Community plugin . Additionally, if you would still like to take advantage of some subset of the default , you’ll need to copy them manually to your local .eslintrc
file.
This is a start to testing for accessibility: can be found below.
to tab through the pages. Can you reach and operate every interactive control (links, buttons, form inputs, etc.) and see a focus indicator on the screen?
Use , or to find and fix common accessibility issues in development
Test for with the
Create inclusive and
Employ accessible
Include
Test for
Ensure accessibility of
Create safe
Write for your site or application
from Google Web Fundamentals
from Smashing Magazine
by Google and Udacity
to web accessibility
, with free online accessibility training for people with disabilities