You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/gatsby-config.md
+141-1Lines changed: 141 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,147 @@ See more about [Browser Support](/docs/browser-support/#polyfills) in Gatsby.
85
85
86
86
## mapping
87
87
88
-
TODO
88
+
---
89
+
title: Gatsby Config
90
+
---
91
+
92
+
Site configuration options for a Gatsby site are placed in a file at the root of the project folder called `gatsby-config.js`.
93
+
94
+
_Note: There are many sample configs which may be helpful to reference in the different [Gatsby Example Websites](https://github.com/gatsbyjs/gatsby/tree/master/examples)._
95
+
96
+
## Configuration options
97
+
98
+
Options available to set within `gatsby-config.js` include:
99
+
100
+
1. siteMetadata (object)
101
+
2. plugins (array)
102
+
3. pathPrefix (string)
103
+
4. polyfill (boolean)
104
+
5. mapping (object)
105
+
6. proxy (object)
106
+
107
+
## siteMetadata
108
+
109
+
When you want to reuse common pieces of data across the site (for example, your site title), you can store that data in `siteMetadata`:
110
+
111
+
```javascript
112
+
module.exports= {
113
+
siteMetadata: {
114
+
title:`Gatsby`,
115
+
siteUrl:`https://www.gatsbyjs.org`,
116
+
description:`Blazing-fast static site generator for React`,
117
+
},
118
+
};
119
+
```
120
+
121
+
This way you can store it in one place, and pull it whenever you need it. If you ever need to update the info, you only have to change it here.
122
+
123
+
See a fuller description and sample usage in [Gatsby.js Tutorial Part Four](/tutorial/part-four/#data-in-gatsby).
124
+
125
+
## plugins
126
+
127
+
Plugins are Node.js packages that implement Gatsby APIs. The config file accepts an array of plugins. Some plugins may need only to be listed by name, while others may take options (see the docs for individual plugins).
128
+
129
+
```javascript
130
+
module.exports= {
131
+
plugins: [
132
+
`gatsby-plugin-react-helmet`,
133
+
{
134
+
resolve:`gatsby-source-filesystem`,
135
+
options: {
136
+
name:`docs`,
137
+
path:`${__dirname}/../docs/`,
138
+
},
139
+
},
140
+
],
141
+
};
142
+
```
143
+
144
+
See more about [Plugins](/docs/plugins/) for more on utilizing plugins, and to see available official and community plugins.
145
+
146
+
## pathPrefix
147
+
148
+
It's common for sites to be hosted somewhere other than the root of their domain. Say we have a Gatsby site at `example.com/blog/`. In this case, we would need a prefix (`/blog`) added to all paths on the site.
149
+
150
+
```javascript
151
+
module.exports= {
152
+
// Note: it must *not* have a trailing slash.
153
+
pathPrefix:`/blog`,
154
+
};
155
+
```
156
+
157
+
See more about [Adding a Path Prefix](/docs/path-prefix/).
158
+
159
+
## polyfill
160
+
161
+
Gatsby uses the ES6 Promise API. Because some browsers don't support this, Gatsby includes a Promise polyfill by default.
162
+
163
+
If you'd like to provide your own Promise polyfill, you can set `polyfill` to false.
164
+
165
+
```javascript
166
+
module.exports= {
167
+
polyfill:false,
168
+
};
169
+
```
170
+
171
+
See more about [Browser Support](/docs/browser-support/#polyfills) in Gatsby.
172
+
173
+
## mapping
174
+
175
+
To query between nodes, Gatsby has a mapping feature which allows you to link two different nodes by id and then you can query with GraphQL. For instance, if you have a couple of blog posts which have author id in the frontmatter:
176
+
177
+
```
178
+
title: A blog post
179
+
author: Kyle Mathews
180
+
```
181
+
182
+
And you have a list of authors and their details stored in `authors.yaml`, you can map between `author` in `frontmatter` to id in `authors.yaml` file by:
0 commit comments