-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(recipe):Creating a new site using a theme #20595
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,6 +4,72 @@ title: "Recipes: Working with Themes" | |||||||||
|
||||||||||
A [Gatsby theme](/docs/themes/what-are-gatsby-themes) abstracts Gatsby configuration (shared functionality, data sourcing, design) into an installable package. This means that the configuration and functionality isn’t directly written into your project, but rather versioned, centrally managed, and installed as a dependency. You can seamlessly update a theme, compose themes together, and even swap out one compatible theme for another. | ||||||||||
|
||||||||||
## Creating a new site using a theme | ||||||||||
|
||||||||||
Found a theme you'd like to use on your project? Awesome! You can work through setting up by following the steps below. | ||||||||||
|
||||||||||
> If you'd like to take a look at more theme options, you could take a look at this [list of themes](https://www.npmjs.com/search?q=gatsby-theme) . | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
### Prerequisities | ||||||||||
|
||||||||||
The [Gatsby CLI](/docs/gatsby-cli) installed | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
### Directions | ||||||||||
|
||||||||||
1. Create a gatsby site | ||||||||||
|
||||||||||
```shell | ||||||||||
gatsby new {your-project-name} | ||||||||||
``` | ||||||||||
|
||||||||||
2. Change directory and install theme | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Thoughts on doing it this way instead of having the additional example snippet? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha! I agree. |
||||||||||
|
||||||||||
```shell | ||||||||||
cd {your-project-name} | ||||||||||
npm install {theme-name} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
``` | ||||||||||
|
||||||||||
For Example | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we take the above recommendation then this whole section is uneeded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea. Thanks 😄 |
||||||||||
|
||||||||||
```shell | ||||||||||
npm install gatsby-theme-blog | ||||||||||
|
||||||||||
``` | ||||||||||
|
||||||||||
3. Add theme to `gatsby.config.js` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```shell | ||||||||||
module.exports = { | ||||||||||
plugins: [ | ||||||||||
{ | ||||||||||
resolve: `gatsby-theme-blog`, | ||||||||||
options: { | ||||||||||
/* | ||||||||||
- basePath defaults to `/` | ||||||||||
- contentPath defaults to `content/posts` | ||||||||||
- assetPath defaults to `content/assets` | ||||||||||
- mdx defaults to `true` | ||||||||||
*/ | ||||||||||
basePath: `/blog`, | ||||||||||
contentPath: `content/blogPosts`, | ||||||||||
assetPath: `content/blogAssets`, | ||||||||||
mdx: false, | ||||||||||
}, | ||||||||||
}, | ||||||||||
], | ||||||||||
} | ||||||||||
``` | ||||||||||
|
||||||||||
4. Run `yarn develop` , the theme should be avaliable at `http://localhost:8000/{basePath}` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on this we likely need to include yarn installation as a pre-req as well? Or can they run gatsby develop instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add yarn to the pre-req. It's used mostly with themes because of Yarn workspaces. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For sure, my question is whether workspaces are necessary for using themes? Or just developing them? The theme starter example uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think workspaces are necessary for using themes. Also, I saw that running yarn develop triggers gatsby develop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So let's try using just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey so I checked and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'd love to understand this a bit better. You're saying that when you create a new gatsby project it's creating a yarn.lock file? That shouldn't be the case as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if someone uses before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||
|
||||||||||
> To learn how to further customize a theme,check out the avaliabe paths on [Gatsby-theme-blog Documentation](https://www.npmjs.com/package/gatsby-theme-blog). | ||||||||||
|
||||||||||
### Additional resources | ||||||||||
|
||||||||||
- To learn how to further customize a theme, check out the docs on [Gatsby theme shadowing.](https://www.gatsbyjs.org/docs/themes/shadowing/) | ||||||||||
|
||||||||||
- You can also [use multiple themes](https://www.gatsbyjs.org/docs/themes/using-multiple-gatsby-themes/) on a project. | ||||||||||
|
||||||||||
## Creating a new site using a theme starter | ||||||||||
|
||||||||||
Creating a site based on a starter that configures a theme follows the same process as creating a site based on a starter that **doesn't** configure a theme. In this example you can use the [starter for creating a new site that uses the official Gatsby blog theme](https://github.com/gatsbyjs/gatsby-starter-blog-theme). | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.