• Stars
    star
    1,164
  • Rank 39,949 (Top 0.8 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📝 Bring WordPress to the static world with Next.js

Next.js WordPress Starter

All Contributors

Scaling WordPress with the power of Next.js and the static web!

⚡️ Quick Start

Deploy to Netlify Deploy with Vercel

Requirements

yarn create next-app -e https://github.com/colbyfayock/next-wordpress-starter
# or
npx create-next-app -e https://github.com/colbyfayock/next-wordpress-starter

Add an .env.local file to the root with the following:

WORDPRESS_GRAPHQL_ENDPOINT="http://wordpressite.com/graphql"

🚀 Getting Started

What is this and what does it include?

The goal of this project is to take WordPress as a headless CMS and use Next.js to create a static experience without any 3rd party services that can be deployed anywhere.

The hope is to build out as many features as we can to support what's typically expected from an out of the box theme on WordPress. Currently, those features include:

Additionally, the theme is expected to be SEO friendly and performant out of the box, including:

  • Unique page titles
  • Unique descriptions
  • Open Graph tags

You can also optionally enable Yoast SEO plugin support to supercharge your SEO! (See below)

Check out the Issues for what's on deck!

Want something a little more basic? Check out my other starter with an MVP setup to get up and running with WPGraphQL in WordPress: https://github.com/colbyfayock/next-wpgraphql-basic-starter

Requirements

Environment

This project makes use of WPGraphQL to query WordPress with GraphQL. In order to make that request to the appropriate endpoint, we need to set a environment variable to let Next.js know where to request the site information from.

Create a new file locally called .env.local and add the following:

WORDPRESS_GRAPHQL_ENDPOINT="[WPGraphQL Endpoint]"

Replace the contents of the variable with your WPGraphQL endpoint. By default, it should resemble [Your Host]/graphql.

Note: environment variables can optionally be statically configured in next.config.js

All Environment Variables

Name Required Default Description
WORDPRESS_GRAPHQL_ENDPOINT Yes - WordPress WPGraphQL endpoint (ex: host.com/graphl)
WORDPRESS_MENU_LOCATION_NAVIGATION No PRIMARY Configures header navigation Menu Location
WORDPRESS_PLUGIN_SEO No false Enables SEO plugin support (true, false)

Please note some themes do not have PRIMARY menu location.

Development

To start the project locally, run:

yarn dev
# or
npm run dev

The project should now be available at http://localhost:3000!

ESLint extension for Visual Studio Code

It is possible to take advantage of this extension to improve the development experience. To set up the ESLint extension in Visual Studio Code add a new folder to the root .vscode. Inside add a file settings.json with the following content:

{
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

With this file ESLint will automatically fix and validate syntax errors and format the code on save (based on Prettier configuration).

Deployment

Netlify

There are two options as to how you can deploy this project to Netlify:

Essential Next.js Plugin should be provided as an option when you're first importing a project based on this starter. If it's not, you can install this plugin using the Netlify Plugins directory. This will allow the project to take full advantage of all native Next.js features that Netlify supports with this plugin.

Exporting the project lets Next.js compile the project into static assets including HTML files. This allows you to deploy the project as a static site directly to Netlify just like any other site. You can do this by adding next export to the end of the build command inside package.json (ex: next build && next export).

Regardless of which option you choose, you can configure your environment variables either when creating your new site or by navigating to Site Settings > Build & Deploy > Environment and triggering a new deploy once added.

Deploy to Netlify

Vercel

Given Next.js is a Vercel-supported project, you can simply import the project as a new site and configure your environment variables by either adding them during import or by navigating to Settings > Environment Variables and triggering a new build once added.

Deploy with Vercel

🛠 Configuring Your Project

package.json

In order to avoid an additional configuration file, we take advantage of some built-in properties of package.json to configure parts of the website.

Name Required Description
homepage Yes Homepage or hostname used to construct full URLs (ex Open Graph)
  • homepage: Setting the homepage property will update instances where the full URL is required such as Open Graph tags

WordPress

This project aims to take advantage of as many built-in WordPress features by default like a typical WordPress theme. Those include:

Name Usage
Site Language lang attribute on the <html> tag
Site Title Homepage header, page metadata
Tagline Homepage subtitle

There is some specific WordPress configuration required to allow for the best use of this starter.

Images

This Starter doesn't currently provide any mechanisms for dealing with image content from WordPress. The images are linked to "as is", meaning if the image is uploaded via the WordPress interface, the image will be served from WordPress.

To serve the images statically, you have a few options.

Jetpack

By enabling the Image Accelerator from Jetpack, your images will automatically be served statically and cached via the wp.com CDN. This feature comes free with the basic installation of Jetpack, requiring only that you connect the WordPress site to the Jetpack service.

Jetpack CDN

🔌 Plugins

Yoast SEO

The Yoast SEO plugin is partially supported including most major features like metadata and open graph customization.

Requirements

  • Yoast SEO plugin
  • Add WPGraphQL SEO plugin

To enable the plugin, configure WORDPRESS_PLUGIN_SEO to be true either as an environment variable or within next.config.js.

🥾 Bootstrapped with Next.js WordPress Starter

Examples of websites that started off with Next.js WordPress Starter

💝 Sponsors

WordPress hosting for the public-facing project provided by WP Engine.

WP Engine Logo

Contributors

Thanks goes to these wonderful people (emoji key):

Colby Fayock
Colby Fayock

💻 📖
Kevin Cunningham
Kevin Cunningham

💻
Guillermo Angulo
Guillermo Angulo

💻
Hein Snyman
Hein Snyman

💻
Grische
Grische

🔧
Jatin Rathee
Jatin Rathee

💻
Dave
Dave

💻
Brad Garropy
Brad Garropy

💻
Fábio Sales
Fábio Sales

💻
Leonardo Losoviz
Leonardo Losoviz

💻
Avneesh Agarwal
Avneesh Agarwal

💻
Phattarapol L.
Phattarapol L.

💻
Peter Cruckshank
Peter Cruckshank

💻
Shane O'Grady
Shane O'Grady

💻
Nick Gaswirth
Nick Gaswirth

💻
alexandruvisan19
alexandruvisan19

💻
Ritik Chourasiya
Ritik Chourasiya

🔧

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

50-projects-for-react-and-the-static-web

⚛ 50 project ideas to learn by doing complete with project briefs, layout ideas, and resources!
861
star
2

next-cloudinary

⚡️ High-performance image delivery and uploading at scale in Next.js powered by Cloudinary.
TypeScript
181
star
3

gatsby-starter-leaflet

🍃 A Gatsby starter with Leafet to quickly build React apps with a map!
JavaScript
115
star
4

next-leaflet-starter

🍃 A Next.js starter with Leafet to quickly build React apps with a map!
JavaScript
102
star
5

html-webpack-partials-plugin

🛠 Easy HTML partials for Webpack without a custom index!
JavaScript
69
star
6

my-final-space-characters

Demo for spacejelly.dev tutorial
JavaScript
68
star
7

space-jelly-store-workshop

JavaScript
49
star
8

coronavirus-map-dashboard

🦠 Coronavirus (COVID-19) Map Dashboard using coronavirus-tracker-api
JavaScript
44
star
9

next-wpgraphql-basic-starter

JavaScript
42
star
10

use-custom-hook

⚛️ A starter template for creating a new React Hook
JavaScript
42
star
11

next-sass-starter

Use Sass to start your Next.js app with CSS superpowers!
JavaScript
40
star
12

cloudinary-examples

Easy Cloudinary integration examples for boosting web performance.
36
star
13

netlify-plugin-cloudinary

Supercharge images on your Netlify site with Cloudinary!
JavaScript
36
star
14

content-reminder

⏰ A GitHub Action that reminds you to share your own content
JavaScript
32
star
15

launchtime-workshop

JavaScript
32
star
16

gatsby-starter-sass

👓 A Gatsby starter with Sass and no assumptions!
JavaScript
31
star
17

colbyfayock.com

Personal blog using Next.js and headless WordPress
JavaScript
25
star
18

minimal.iOS.8

Minimal iOS 8 Winterboard theme
JavaScript
25
star
19

my-rick-and-morty-wiki

Demo for spacejelly.dev tutorial
JavaScript
23
star
20

imagecarbon

JavaScript
22
star
21

tweet

Netlify function to post a tweet to Twitter!
JavaScript
21
star
22

use-snipcart

A React hook for checking in to Snipcart state.
JavaScript
18
star
23

my-coronavirus-map

Demo for colbyfayock.com tutorial
JavaScript
17
star
24

my-futurama-characters

Demo for spacejelly.dev tutorial
JavaScript
16
star
25

spacejelly.dev

The best web dev tutorials in the galaxy!
HTML
16
star
26

my-posts-app

Demo for From Design to Development Crash Course
JavaScript
15
star
27

gatsby-starter-docz-netlifycms

Quickly deploy Docz documentation powered by Netlify CMS!
JavaScript
14
star
28

my-email-app

Demo for spacejelly.dev tutorial
JavaScript
14
star
29

gatsby-plugin-google-marketing-platform

Gatsby plugin for the Google Marketing Platform (GTM, GA, GO)
JavaScript
14
star
30

my-space-jelly-gear

Demo for egghead.io course
JavaScript
13
star
31

rick-and-morty-wiki

Demo for a tutorial walking through building a Rick and Morty Character Wiki in Next.js
JavaScript
13
star
32

my-scrolly-event

Demo for spacejelly.dev tutorial
JavaScript
13
star
33

my-husky-project

Demo for tutorial
JavaScript
12
star
34

use-placecage

A React hook for placecage.com
JavaScript
12
star
35

my-image-uploader

Demo for spacejelly.dev tutorial
JavaScript
12
star
36

my-spacex-launches

Demo for spacejelly.dev tutorial
JavaScript
12
star
37

my-openai-app

Demo for egghead.io course
JavaScript
11
star
38

hyper-bros-trading-workshop-github-universe

Learn how to build an online store with Next.js, Snipcart, and Netlify!
11
star
39

my-ecommerce-app

Demo for Level Up Tutorials course
JavaScript
11
star
40

minimal.iOS.9

Minimal iOS 9 Winterboard theme
JavaScript
11
star
41

my-react-email

Demo for spacejelly.dev tutorial
TypeScript
10
star
42

space-jelly-twitch-bot

JavaScript
9
star
43

gatsby-recipe-react-leaflet

🍃 A Gatsby Recipe for React Leaflet
JavaScript
9
star
44

santa-tracker

Demo mapping app for tracking Santa 🎅
JavaScript
9
star
45

next-redirect-manager

Dashboard for adding, removing, and viewing Vercel redirects.
JavaScript
9
star
46

space-jelly-gear-starter

JavaScript
9
star
47

my-next-mdx

Demo for spacejelly.dev tutorial
JavaScript
8
star
48

wwdc-memoji

Create your own WWDC Memoji!
JavaScript
8
star
49

cloudinary-util

JavaScript
8
star
50

md-to-wp

Upload a directory of markdown files to WordPress
JavaScript
8
star
51

cloudinary-transform-designer

Design your image transformation with Cloudinary
JavaScript
8
star
52

my-cloudinary-images

Demo for spacejelly.dev tutorial
JavaScript
8
star
53

my-livebeat

Course demo for Full Stack React with Appwrite
TypeScript
8
star
54

my-seo-app

Demo for spacejelly.dev tutorial
JavaScript
7
star
55

demo-image-upload-starter

https://demo-image-upload-starter.netlify.app
JavaScript
7
star
56

my-github-actions

Demo for spacejelly.dev tutorial
JavaScript
7
star
57

egghead-code-examples

Code examples for Egghead lessons
JavaScript
7
star
58

my-css-loading-animation-static

Demo for spacejelly.dev tutorial
HTML
6
star
59

demo-image-list-starter

JavaScript
6
star
60

cloudinary-pdf-viewer

POC for viewing a PDF programmatically with Cloudinary
JavaScript
6
star
61

my-nextauth-twitter

Demo for spacejelly.dev tutorial
JavaScript
6
star
62

demo-github-profile-starter

JavaScript
6
star
63

gats-bs

JavaScript
6
star
64

amazon-goldbox

Grabs and dumps Amazon's Goldbox RSS into an S3 bucket for affiliate usage
JavaScript
6
star
65

hyper-bros-trading-workshop

Learn how to build an online store with Next.js, Snipcart, and Netlify!
6
star
66

my-contact-form

Demo for spacejelly.dev tutorial
TypeScript
6
star
67

my-next-sass-app

Demo for tutorial
JavaScript
6
star
68

my-next-cloudinary

Demo for spacejelly.dev tutorial
JavaScript
6
star
69

my-puppeteer-function

Demo for spacejelly.dev tutorial
JavaScript
6
star
70

thank-you-action

JavaScript
5
star
71

my-css-loading-animation-dynamic

Demo for spacejelly.dev tutorial
JavaScript
5
star
72

media-ecommerce-workshop

5
star
73

50reactprojects.com

JavaScript
5
star
74

space-jelly-store

JavaScript
5
star
75

my-fresh-blog

Demo for spacejelly.dev tutorial
JavaScript
5
star
76

my-next-eslint

Demo for spacejelly.dev tutorial
JavaScript
5
star
77

my-react-file-upload

Demo for spacejelly.dev tutorial
TypeScript
4
star
78

my-tagged-uploads

Demo for spacejelly.dev tutorial
JavaScript
4
star
79

astro-image-gallery

CSS
4
star
80

revue-convertkit-sync

Automatically sync Revue subscribers to Convertkit with GitHub Actions
JavaScript
4
star
81

my-tailwind-static

Demo for spacejelly.dev tutorial
HTML
4
star
82

my-pokemon-generator

Demo for spacejelly.dev tutorial
JavaScript
4
star
83

my-long-press

Demo for spacejelly.dev tutorial
JavaScript
4
star
84

hyper-bros-trading-workshop-starter

Starter for workshop Build an Online Store with Next.js, Snipcart, and Netlify
JavaScript
4
star
85

cloudinary-nextauthjs

JavaScript
4
star
86

my-tailwind-dynamic

Demo for spacejelly.dev tutorial
CSS
4
star
87

my-swapi-search

Demo for spacejelly.dev tutorial
JavaScript
4
star
88

netlify-cms-editor-component-figure

Native HTML figure element for Netlify CMS
JavaScript
4
star
89

demo-next-function-starter

JavaScript
4
star
90

cloudycam

JavaScript
4
star
91

my-santa-tracker

Demo for colbyfayock.com tutorial
JavaScript
4
star
92

my-search-events

Demo for spacejelly.dev tutorial
JavaScript
4
star
93

my-chakra-app

Demo for tutorial
JavaScript
4
star
94

space-jelly-cron

JavaScript
3
star
95

my-pinned-repos

Demo for spacejelly.dev tutorial
JavaScript
3
star
96

cloudinary-image-function

JavaScript
3
star
97

my-testing-app

Demo for spacejelly.dev tutorial
JavaScript
3
star
98

my-mapbox-gatsby-starter-leaflet

Demo for spacejelly.dev tutorial
JavaScript
3
star
99

my-sanity-store

Demo for egghead.io tutorial
JavaScript
3
star
100

my-last-airbender-wiki

Demo for spacejelly.dev tutorial
JavaScript
3
star