How it works:
Grabs existing WordPress content and generates an equivalent static page for each post, page, taxonomy, author, etc.
Demo: https://wpgatsby.dev/
Features:
- 🚀 Responsive, fast-loading, animated
- 🎨 Customizable theme with Chakra-UI
- ⭐ Custom landing page
- 🌙 Dark-mode support
- 💌 Built-in newsletter form with MailChimp
- ⚡ Minimal WordPress setup
- 📄 Support for post, page, category, tag and author types
-
Install.
Use the Gatsby CLI (install instructions) to create a new site, specifying the wpgatsby starter.
# Install wp-gatsby: gatsby new my-app https://github.com/ansmlc/wpgatsby
-
Configure WordPress.
-
Install and activate these plugins in a live WordPress instance:
-
Configure GraphQL.
In
gatsby-config.js
undergatsby-source-wordpress
pointurl
to your WPGraphQL endpoint. E.g.https://yoursite.com/graphql
-
Start developing.
Navigate into your new site’s directory and start it up.
cd my-app/ gatsby develop
Your site is now running in development mode at
http://localhost:8000
!_Note: You'll also see a second link:
http://localhost:8000/___graphql
. This is a tool you can use to experiment with querying your data.
...
Coming soon
...
A quick look at important files and directories you'll see in this Gatsby project.
.
├── node_modules
├── src
├── @chakra-ui
├── components
├── pages
├── templates
├── static
├── .gitignore
├── .prettierrc
├── gatsby-browser.js
├── gatsby-config.js
├── gatsby-node.js
├── gatsby-ssr.js
├── LICENSE
├── package-lock.json
├── package.json
└── README.md
...
Coming soon
...
How to setup WordPress and other data to work with wp-gatsby:
- Add menus titled "GP-HEADER" and "GP-FOOTER"
- Add some pages to menus
- Set permalink settings to "Post name".
- Add posts with featured images
- Add tags and categories
- Add some posts to "featured" category (to show on homepage)
Logo can be set in several ways:
-
SVG from React component (default)
- Put your SVG in
customSvgLogo.js
insrc/components/svgs
- Edit
gatsby-config.js
with the following option:
module.exports = { siteMetadata: { customLogoComponent: true, } }
⚠️ Set this option tofalse
if you wish to use any of the bellow options - Put your SVG in
-
From WP Media Library (JPEG or PNG)
- Upload and set image title to
"gp-logo"
.
- Upload and set image title to
-
From Gatsby's static directory (JPEG, PNG or SVG)
- Add logo named
"gp-logo"
tosrc/static/images
directory.
- Add logo named
-
If no image is found logo will be generated based on WordPress site name.
Edit the theme.js
file to customize variables like
colors, fonts, border-radius and edit global styles of existing components
src/@chakra-ui/theme.js
-
Get the MailChimp endpoint
-
Go to MailChimp dashboard:
Audience –> Signup Forms –> Embedded Form
-
Generate a form and copy the first URL you see (from the
POST
method) -
Paste the endpoint URL into gatsby-config.js:
-
plugins: [
{
resolve: "gatsby-plugin-mailchimp",
options: {
# example URL
endpoint: 'https://name.list-manage.com/subscribe/post?u=4754c309a8',
timeout: 3500,
},
},
]
- Paste URL in gatsby-config.js
Edit gatsby-config.js
and add URLs to your social networks:
module.exports = {
siteMetadata: {
# Social icons URLs /
# If not using leave it empty ( `` ) / Do not delete field
socialLinks: {
facebook: `https://facebook.com`,
instagram: `https://instagram.com`,
linkedin: `https://linkedin.com`,
youtube: `https://youtube.com`,
twitter: ``,
},
},