diff --git a/docs/tutorial/part-three/about-uncentered.png b/docs/tutorial/part-three/about-uncentered.png new file mode 100644 index 0000000000000..791eae584d85c Binary files /dev/null and b/docs/tutorial/part-three/about-uncentered.png differ diff --git a/docs/tutorial/part-three/index.md b/docs/tutorial/part-three/index.md index 1d5cec9ead2fe..43f79803e5ec2 100644 --- a/docs/tutorial/part-three/index.md +++ b/docs/tutorial/part-three/index.md @@ -7,59 +7,75 @@ Welcome to part three! ## What's in this tutorial? -In this part, you'll learn about creating "layout" components. Layout components are for -sections of your site that you want to share across multiple pages. For example, -Gatsby sites will commonly have a layout component with a shared header and -footer. Other common things to add to layouts are a sidebar and/or navigation menu. +In this part, you'll learn about Gatsby plugins, and creating "layout" components. -On this page for example, the header at the top is part of gatsbyjs.org's layout component. +Gatsby plugins are JavaScript packages that help add functionality to a Gatsby site. Gatsby is designed to be extensible, which means plugins are able to extend and modify just about everything Gatsby does. -Let's dive in and explore creating layouts. +Layout components are for sections of your site that you want to share across multiple pages. For example, sites will commonly have a layout component with a shared header and footer. Other common things to add to layouts are a sidebar and/or navigation menu. On this page for example, the header at the top is part of gatsbyjs.org's layout component. -## Install a starter +Let's dive in to part three. -As we mentioned in Part Two, at this point it's probably a good idea to close the terminal window(s) and project files from previous parts of the tutorial, to keep things clean on your desktop. Then, open a new terminal window and run the following commands to create a new Gatsby site in a directory called `tutorial-part-three` and then move to this new directory: +## Using plugins -```shell -gatsby new tutorial-part-three https://github.com/gatsbyjs/gatsby-starter-hello-world -cd tutorial-part-three -``` +You’re probably familiar with the idea of plugins. Many software systems support adding custom plugins to add new functionality or even modify the core workings of the software. Gatsby plugins work the same way. + +Community members (like you!) can contribute plugins (small amounts of JavaScript code) that others can then use when building Gatsby sites. + +> There are already hundreds of plugins! Explore the Gatsby [Plugin Library](/plugins/). + +Our goal with plugins is to make them straightforward to install and use. You will likely be using plugins in almost every Gatsby site you build. While working through the rest of the tutorial you’ll have many opportunities to practice installing and using plugins. -Once the site is finished installing, install `gatsby-plugin-typography`. For a reminder of how to do this, see [Part Two](/tutorial/part-two/) of the tutorials. For -the Typography.js theme, try the "Fairy Gates" typography theme this time: +For an initial introduction to using plugins, we'll install and implement the Gatsby plugin for Typography.js. + +[Typography.js](https://kyleamathews.github.io/typography.js/) is a JavaScript library which generates global base styles for your site's typography. The library has a [corresponding Gatsby plugin](/packages/gatsby-plugin-typography/) to streamline using it in a Gatsby site. + +### ✋ Create a new Gatsby site + +As we mentioned in [part two](/tutorial/part-two/), at this point it's probably a good idea to close the terminal window(s) and project files from previous parts of the tutorial, to keep things clean on your desktop. Then, open a new terminal window and run the following commands to create a new Gatsby site in a directory called `tutorial-part-three` and then move to this new directory: ```shell -npm install --save gatsby-plugin-typography react-typography typography typography-theme-fairy-gates +gatsby new tutorial-part-three https://github.com/gatsbyjs/gatsby-starter-hello-world +cd tutorial-part-three ``` -Create a `src/utils` directory, and then create the typography config file at `src/utils/typography.js`: +### ✋ Install and configure `gatsby-plugin-typography` -```javascript:title=src/utils/typography.js -import Typography from "typography" -import fairyGateTheme from "typography-theme-fairy-gates" +There are two main steps to using a plugin: Installing and configuring. -const typography = new Typography(fairyGateTheme) +1. Install the `gatsby-plugin-typography` NPM package. -export default typography +```shell +npm install --save gatsby-plugin-typography react-typography typography ``` -Then create your site's `gatsby-config.js` at the root of the site, and add the following code to it: +> Note: Typography.js requires a few additional packages, so those are included in the instructions. Additional requirements like this will be listed in the "install" instructions of each plugin. + +2. Create a new file in the root of your project called `gatsby-config.js`, and copy the following into the file: ```javascript:title=gatsby-config.js module.exports = { - plugins: [ - { - resolve: `gatsby-plugin-typography`, - options: { - pathToConfigModule: `src/utils/typography.js`, - }, - }, - ], + plugins: [`gatsby-plugin-typography`], } ``` -Now, you can add a few different pages: a front page, an about page, and a contact -page. +The `gatsby-config.js` is another special file that Gatsby will automatically recognize. This is where you add plugins and other site configuration. + +> Check out the [doc on `gatsby-config.js`](/docs/gatsby-config/) to read more, if you wish. + +3. Start the development server. + +```shell +gatsby develop +``` + +Once you load the site, if you inspect the generated HTML using the Chrome developer tools, you’ll see that the typography plugin added a `