SlideShare a Scribd company logo
1 of 42
Hello
a. Install Node JS (recommended v8.11 LTS)
• https://nodejs.org/en/
b. Install GIT
• https://git-scm.com/
c. Install Gatsby CLI
$ npm install --global gatsby-cli
Using the WordPress REST API &
Gatsby.js to build a static website
indigotree.co.uk
@indigotreesays
#indigoteam
indigotree.co.uk
@indigotreesays
Overview
1. Objective and Requirements
2. Introduction to Gatsby.js and Examples
3. Pitfalls and Challenges
4. Build Your Website
Objective and
Requirements
Objective of this Workshop
• Introduce Gatsby.js and the benefits of a
headless approach
• Discuss some of the pitfalls and challenges of
this approach
• Show you how to use Gatsby.js to build a simple
website using our example and the WordPress
Rest API
Requirements
• A laptop
• An internet connection
• Development environment that supports
– Node (v6 onwards)
– NPM (v3 onwards)
– GIT
• Basic development experience
Nice to have:
• Experience with JS, React, GraphQL & Static Site
Generators
• Familiarity with Terminal/CLI
Introduction to
Gatsby.js and
Examples
● Create document-based sites
● HTML, CSS, JS
● Does not include native asset pipelining
● Refresh to view changes
● Full page reloads
● php and mySQL
● Create app-like experiences
● Code splitting, responsive images, etc
● Virtual DOM & declarative UI with React
● Componentization
● Hot reloading
● ES6 + ES7 automatically transpiled
Gatsby=>
Performance
● Offline & caching = great for users even on 3G
● Initial call loads site; critical elements inlined
● Predict likely pages to be visited and prefetch in
background making link clicks instantaneous
Data and CMS Agnostic
● Pull data from anywhere
● Build with React and GraphQL
Global deployment
WordPress: website deployment
requires hosting experience and
can be expense to achieve…
● Content delivery network
● Global load balancing
● Server redundancy and
failover
● Continuous deployment and
integration
● Performance and error
profiling
● Security vulnerabilities
Gatsby: website deployment
easy and free..
● Content delivery network
● Global load balancing
● Server redundancy and
failover
● Continuous deployment and
integration
Build + Run
Client: VSNi
vsni-demo.indigotree.co.uk/
Example: Workshop
wcbtn2018.indigotree.co.uk
About (static page)
Contact (static page)
Articles (post archive)
Article (post)
WordPress
Pages
Posts
Plugins
- ACF
- ACF to rest API
- Yoast
- GatsbyWorkshop (Indigo)
gatsbyworkshop.wpengine.com
Pitfalls and
Challenges
Pitfalls
• What used to work in WordPress does not work any
more – e.g. form plugins will not work
• More flexibility but need to do more work yourself
• Gutenberg should not make any difference
• We can add individual blocks into the rest API but
there is nothing currently in Gatsby that understands
blocks
Challenges
Site Preview
• Not instant, takes a few seconds to generate the site
Images
• Featured images are pulled in and stored on the Gatsby
site, lazy loading works BUT other images within page
content are pulled from the WordPress site
• We recommend Cloudinary for image hosting
Forms
• We often use Netlify forms or can write a Lambda
function
Comments
• Use third-party like Disqus or write a Lambda function
Building Your
Website
Instructions
https://github.com/indigotree/gatsbyworkshop-
wc2018-starter/
0. Installation
a. Install Node JS (recommended v8.11 LTS)
• If you already have Node JS, you can skip this step.
• You can download & install Node JS from here:
https://nodejs.org/en/
b. Install GIT
• If you're on Mac, GIT should already be available through
xcode tools, and if you're in Windows, you can download
it from here: https://git-scm.com/
0. Installation
c. Install Gatsby CLI
$ npm install --global gatsby-cli
If you have problems installing packages globally, then
consider one of these approaches:
https://docs.npmjs.com/getting-started/fixing-npm-
permissions
d. Create your Gatsby Site
$ cd ~/Desktop
$ gatsby new wcbtn-gatsby
https://github.com/indigotree/gatsbyworkshop-
wc2018-starter.git
$ cd ./wcbtn-gatsby
$ gatsby develop
1. Query GraphQL for all WordPress pages
Gatsby doesn't create pages automatically, we need to
query all of our WordPress pages and create physical pages
for them.
We first need to query for the WordPress pages. Add this
within gatsby-node.js to define the query.
2. Run the GraphQL query, and loop through
the results
Still inside gatsby-node.js, we need to run the
GraphQL query, which will return back all of the pages that
matched our query. Here we can loop over those pages
ready for step 3 where we create the Gatsby pages.
3. Create pages with Gatsby
We can use the createPage function from Gatsby to
create physical pages on our site. This code can be added
within the loop that we wrote in step 2..
4. Create the page.js page template
Every page created by createPage() needs to have a
template. Let's start by adding an empty template to
output the page title & content. Create a file at
src/templates/page.js and add the following:
5. Re-run the gatsby-develop command
As we have now made changes with how Gatsby handles
the WordPress content. We need to re run the gatsby
develop command.
You will first need to cancel the current process with CTRL
+ C and then run gatsby develop.
6. Check Gatsby has created the pages
This should create a Gatsby page for each of our WordPress
pages.
If you visit http://localhost:8000/nope, which is
the Gatsby dev 404 page, you should be able to see a list of
all pages created by Gatbsy.
Try to visit one of the pages Gatsby has created for us, such
as http://localhost:8000/about where we
should see our title & content from WordPress.
7. Improving our page.js template
Update our src/templates/page.js template to
include the following code:
8. Tell Gatsby to use our homepage template
During step 3, in gatsby-node.js, we told Gatsby to
create all pages using our page.js template. But as we
would like our homepage to use a different template, we
can add a check to see which page is being created and
provide Gatsby with the correct template to use.
Next, we need to remove the temporary homepage that
you can find at src/pages/index.js. Simply delete
this file.
9. Re-run the gatsby-develop command
As we have now made changes with how Gatsby handles
the WordPress content. We need to re run the gatsby
develop command.
You will first need to cancel the current process with CTRL
+ C and then run gatsby develop.
10. Next Steps
Add the posts and archive
• We have added news articles in the WordPress site
• We have added react components in our code
So you will need to:
• Setup your Gatsby templates
• Pull in articles through gatsby-node.js
The commit which contains all of the code for the
news/articles ...
• https://github.com/indigotree/gatsbyworkshop-
wc2018/commit/15189a701d4a48b41f6477c29b0d2c96
e701bc85
Hosting
We recommend Netlify https://www.netlify.com/
1. Push up code to your Git repo
2. Sign up to Netlify https://app.netlify.com/signup
3. Connect Netlify with your Git Repo
Useful Links
The demo website ...
https://wcbtn2018.indigotree.co.uk/
The code for the entire demo website ...
https://github.com/indigotree/gatsbyworkshop-wc2018
The starter repo for the workshop ...
https://github.com/indigotree/gatsbyworkshop-wc2018-starter
The completed code for the workshop ...
https://github.com/indigotree/gatsbyworkshop-wc2018-complete
The commit which contains all of the workshop code we're asking you to add ...
https://github.com/indigotree/gatsbyworkshop-
wc2018/commit/12ea9c2d5c343c29460dbcc5d430c9f3ae681105
The commit which contains all of the code for the news/articles ...
https://github.com/indigotree/gatsbyworkshop-
wc2018/commit/15189a701d4a48b41f6477c29b0d2c96e701bc85
WordPress plugin…
https://github.com/indigotree/gatsbyworkshop-wc2018-wp-plugin
Gatsby documentation
https://www.gatsbyjs.org/
indigotree.co.uk
@indigotreesays

More Related Content

What's hot

Using Search Intent in our Link Building Efforts
Using Search Intent in our Link Building EffortsUsing Search Intent in our Link Building Efforts
Using Search Intent in our Link Building EffortsChris Czermak
 
The Full Scoop on Google's Title Rewrites
The Full Scoop on Google's Title RewritesThe Full Scoop on Google's Title Rewrites
The Full Scoop on Google's Title RewritesMordy Oberstein
 
How to Use Search Intent to Dominate Google Discover
How to Use Search Intent to Dominate Google DiscoverHow to Use Search Intent to Dominate Google Discover
How to Use Search Intent to Dominate Google DiscoverFelipe Bazon
 
Lucy Dodds - BrightonSEO Autumn 22
Lucy Dodds - BrightonSEO Autumn 22Lucy Dodds - BrightonSEO Autumn 22
Lucy Dodds - BrightonSEO Autumn 22Lucy Dodds
 
Tips for optimising for Google Discover
Tips for optimising for Google DiscoverTips for optimising for Google Discover
Tips for optimising for Google DiscoverLucinda Wood
 
How To EAT Links.pptx
How To EAT Links.pptxHow To EAT Links.pptx
How To EAT Links.pptxDixon Jones
 
Diginius - DuckDuckGo, Privacy and the Future of Search
Diginius - DuckDuckGo, Privacy and the Future of Search Diginius - DuckDuckGo, Privacy and the Future of Search
Diginius - DuckDuckGo, Privacy and the Future of Search NateBurke1
 
How to improve Core Web Vitals on a WordPress website
How to improve Core Web Vitals on a WordPress websiteHow to improve Core Web Vitals on a WordPress website
How to improve Core Web Vitals on a WordPress websiteIndigo Tree Digital
 
EAT: Have We Been Looking At It Backwards
EAT: Have We Been Looking At It BackwardsEAT: Have We Been Looking At It Backwards
EAT: Have We Been Looking At It BackwardsEdwardZiubrzynski1
 
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)Gianna Brachetti-Truskawa 🐙
 
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...Martijn Scheijbeler
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxAaron Weaver
 
Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022
Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022
Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022Lucia Lecesne
 
Negotiating crawl budget with googlebots
Negotiating crawl budget with googlebotsNegotiating crawl budget with googlebots
Negotiating crawl budget with googlebotsDawn Anderson MSc DigM
 
How to Kick Ass at Internal Linking
How to Kick Ass at Internal Linking How to Kick Ass at Internal Linking
How to Kick Ass at Internal Linking Martin Hayman
 
BrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdf
BrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdfBrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdf
BrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdf🇺🇲 🇬🇧 Kara Thurkettle
 
How to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectHow to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectRenoir Boulanger
 
SEO at Scale - BrightonSEO April 2022
SEO at Scale - BrightonSEO April 2022SEO at Scale - BrightonSEO April 2022
SEO at Scale - BrightonSEO April 2022Nitin Manchanda
 
Intro tot language models voor SEO
Intro tot language models voor SEOIntro tot language models voor SEO
Intro tot language models voor SEOMichael Van Den Reym
 

What's hot (20)

Using Search Intent in our Link Building Efforts
Using Search Intent in our Link Building EffortsUsing Search Intent in our Link Building Efforts
Using Search Intent in our Link Building Efforts
 
The Full Scoop on Google's Title Rewrites
The Full Scoop on Google's Title RewritesThe Full Scoop on Google's Title Rewrites
The Full Scoop on Google's Title Rewrites
 
How to Use Search Intent to Dominate Google Discover
How to Use Search Intent to Dominate Google DiscoverHow to Use Search Intent to Dominate Google Discover
How to Use Search Intent to Dominate Google Discover
 
Seo report [template]
Seo report [template]Seo report [template]
Seo report [template]
 
Lucy Dodds - BrightonSEO Autumn 22
Lucy Dodds - BrightonSEO Autumn 22Lucy Dodds - BrightonSEO Autumn 22
Lucy Dodds - BrightonSEO Autumn 22
 
Tips for optimising for Google Discover
Tips for optimising for Google DiscoverTips for optimising for Google Discover
Tips for optimising for Google Discover
 
How To EAT Links.pptx
How To EAT Links.pptxHow To EAT Links.pptx
How To EAT Links.pptx
 
Diginius - DuckDuckGo, Privacy and the Future of Search
Diginius - DuckDuckGo, Privacy and the Future of Search Diginius - DuckDuckGo, Privacy and the Future of Search
Diginius - DuckDuckGo, Privacy and the Future of Search
 
How to improve Core Web Vitals on a WordPress website
How to improve Core Web Vitals on a WordPress websiteHow to improve Core Web Vitals on a WordPress website
How to improve Core Web Vitals on a WordPress website
 
EAT: Have We Been Looking At It Backwards
EAT: Have We Been Looking At It BackwardsEAT: Have We Been Looking At It Backwards
EAT: Have We Been Looking At It Backwards
 
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
 
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
 
Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
 
Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022
Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022
Switching domain 3 months before an IPO - Lucia Lecesne - BrightonSEO April 2022
 
Negotiating crawl budget with googlebots
Negotiating crawl budget with googlebotsNegotiating crawl budget with googlebots
Negotiating crawl budget with googlebots
 
How to Kick Ass at Internal Linking
How to Kick Ass at Internal Linking How to Kick Ass at Internal Linking
How to Kick Ass at Internal Linking
 
BrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdf
BrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdfBrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdf
BrightonSEO April 2022 - Kara Thurkettle - Search in the Metaverse.pdf
 
How to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectHow to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS project
 
SEO at Scale - BrightonSEO April 2022
SEO at Scale - BrightonSEO April 2022SEO at Scale - BrightonSEO April 2022
SEO at Scale - BrightonSEO April 2022
 
Intro tot language models voor SEO
Intro tot language models voor SEOIntro tot language models voor SEO
Intro tot language models voor SEO
 

Similar to Using the WordPress REST API and Gatsby.js

Великолепный Gatsby.js | Odessa Frontend Meetup #19
Великолепный Gatsby.js | Odessa Frontend Meetup #19Великолепный Gatsby.js | Odessa Frontend Meetup #19
Великолепный Gatsby.js | Odessa Frontend Meetup #19OdessaFrontend
 
Build Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyImran Sayed
 
Harness The Power Of ACF For Gatsby and WordPress
Harness The Power Of ACF For Gatsby and WordPressHarness The Power Of ACF For Gatsby and WordPress
Harness The Power Of ACF For Gatsby and WordPressImran Sayed
 
Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...
Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...
Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...rtCamp
 
Top 8 react static site generators for 2020
Top 8 react static site generators for 2020Top 8 react static site generators for 2020
Top 8 react static site generators for 2020Katy Slemon
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0Tobias Meixner
 
Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!Gatsbyjs
 
Pre-render Blazor WebAssembly on static web hosting at publishing time
Pre-render Blazor WebAssembly on static web hosting at publishing timePre-render Blazor WebAssembly on static web hosting at publishing time
Pre-render Blazor WebAssembly on static web hosting at publishing timeJun-ichi Sakamoto
 
JAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stackJAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stackzonathen
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5Derek Jacoby
 
Top React Static Site Generators for 2022.pdf
Top React Static Site Generators for 2022.pdfTop React Static Site Generators for 2022.pdf
Top React Static Site Generators for 2022.pdfKaty Slemon
 
The Future Is The Cloud
The Future Is The CloudThe Future Is The Cloud
The Future Is The CloudGatsbyjs
 
Page object from the ground up.ppt
Page object from the ground up.pptPage object from the ground up.ppt
Page object from the ground up.pptJoseph Beale
 
Page object from the ground up by Joe Beale
Page object from the ground up by Joe BealePage object from the ground up by Joe Beale
Page object from the ground up by Joe BealeQA or the Highway
 
Pump up the JAM with Gatsby
Pump up the JAM with GatsbyPump up the JAM with Gatsby
Pump up the JAM with GatsbyStefan Adolf
 
WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?Alexandr Skachkov
 
JS digest. April 2018
JS digest. April 2018JS digest. April 2018
JS digest. April 2018ElifTech
 
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJSFestUA
 
Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20kraqa
 

Similar to Using the WordPress REST API and Gatsby.js (20)

Великолепный Gatsby.js | Odessa Frontend Meetup #19
Великолепный Gatsby.js | Odessa Frontend Meetup #19Великолепный Gatsby.js | Odessa Frontend Meetup #19
Великолепный Gatsby.js | Odessa Frontend Meetup #19
 
Build Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With Gatsby
 
Harness The Power Of ACF For Gatsby and WordPress
Harness The Power Of ACF For Gatsby and WordPressHarness The Power Of ACF For Gatsby and WordPress
Harness The Power Of ACF For Gatsby and WordPress
 
Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...
Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...
Build Your Blazing Fast Site with Gatsby and WordPress @ WordSesh by Muhammad...
 
Top 8 react static site generators for 2020
Top 8 react static site generators for 2020Top 8 react static site generators for 2020
Top 8 react static site generators for 2020
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0
 
Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!
 
Pre-render Blazor WebAssembly on static web hosting at publishing time
Pre-render Blazor WebAssembly on static web hosting at publishing timePre-render Blazor WebAssembly on static web hosting at publishing time
Pre-render Blazor WebAssembly on static web hosting at publishing time
 
JAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stackJAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stack
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5
 
Top React Static Site Generators for 2022.pdf
Top React Static Site Generators for 2022.pdfTop React Static Site Generators for 2022.pdf
Top React Static Site Generators for 2022.pdf
 
The Future Is The Cloud
The Future Is The CloudThe Future Is The Cloud
The Future Is The Cloud
 
Page object from the ground up.ppt
Page object from the ground up.pptPage object from the ground up.ppt
Page object from the ground up.ppt
 
Page object from the ground up by Joe Beale
Page object from the ground up by Joe BealePage object from the ground up by Joe Beale
Page object from the ground up by Joe Beale
 
Pump up the JAM with Gatsby
Pump up the JAM with GatsbyPump up the JAM with Gatsby
Pump up the JAM with Gatsby
 
WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?
 
JS digest. April 2018
JS digest. April 2018JS digest. April 2018
JS digest. April 2018
 
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
 
Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20Stanislaw potoczny kra_qa_21.01.20
Stanislaw potoczny kra_qa_21.01.20
 
Meetup gitbook
Meetup gitbookMeetup gitbook
Meetup gitbook
 

Recently uploaded

₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
 
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...SUHANI PANDEY
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Datingkojalkojal131
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Delhi Call girls
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...SUHANI PANDEY
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.soniya singh
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 

Recently uploaded (20)

VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 

Using the WordPress REST API and Gatsby.js

  • 1. Hello a. Install Node JS (recommended v8.11 LTS) • https://nodejs.org/en/ b. Install GIT • https://git-scm.com/ c. Install Gatsby CLI $ npm install --global gatsby-cli
  • 2. Using the WordPress REST API & Gatsby.js to build a static website indigotree.co.uk @indigotreesays
  • 4. Overview 1. Objective and Requirements 2. Introduction to Gatsby.js and Examples 3. Pitfalls and Challenges 4. Build Your Website
  • 6. Objective of this Workshop • Introduce Gatsby.js and the benefits of a headless approach • Discuss some of the pitfalls and challenges of this approach • Show you how to use Gatsby.js to build a simple website using our example and the WordPress Rest API
  • 7. Requirements • A laptop • An internet connection • Development environment that supports – Node (v6 onwards) – NPM (v3 onwards) – GIT • Basic development experience Nice to have: • Experience with JS, React, GraphQL & Static Site Generators • Familiarity with Terminal/CLI
  • 9. ● Create document-based sites ● HTML, CSS, JS ● Does not include native asset pipelining ● Refresh to view changes ● Full page reloads ● php and mySQL
  • 10. ● Create app-like experiences ● Code splitting, responsive images, etc ● Virtual DOM & declarative UI with React ● Componentization ● Hot reloading ● ES6 + ES7 automatically transpiled Gatsby=>
  • 11. Performance ● Offline & caching = great for users even on 3G ● Initial call loads site; critical elements inlined ● Predict likely pages to be visited and prefetch in background making link clicks instantaneous
  • 12. Data and CMS Agnostic ● Pull data from anywhere ● Build with React and GraphQL
  • 13. Global deployment WordPress: website deployment requires hosting experience and can be expense to achieve… ● Content delivery network ● Global load balancing ● Server redundancy and failover ● Continuous deployment and integration ● Performance and error profiling ● Security vulnerabilities Gatsby: website deployment easy and free.. ● Content delivery network ● Global load balancing ● Server redundancy and failover ● Continuous deployment and integration
  • 21. WordPress Pages Posts Plugins - ACF - ACF to rest API - Yoast - GatsbyWorkshop (Indigo) gatsbyworkshop.wpengine.com
  • 23. Pitfalls • What used to work in WordPress does not work any more – e.g. form plugins will not work • More flexibility but need to do more work yourself • Gutenberg should not make any difference • We can add individual blocks into the rest API but there is nothing currently in Gatsby that understands blocks
  • 24. Challenges Site Preview • Not instant, takes a few seconds to generate the site Images • Featured images are pulled in and stored on the Gatsby site, lazy loading works BUT other images within page content are pulled from the WordPress site • We recommend Cloudinary for image hosting Forms • We often use Netlify forms or can write a Lambda function Comments • Use third-party like Disqus or write a Lambda function
  • 27. 0. Installation a. Install Node JS (recommended v8.11 LTS) • If you already have Node JS, you can skip this step. • You can download & install Node JS from here: https://nodejs.org/en/ b. Install GIT • If you're on Mac, GIT should already be available through xcode tools, and if you're in Windows, you can download it from here: https://git-scm.com/
  • 28. 0. Installation c. Install Gatsby CLI $ npm install --global gatsby-cli If you have problems installing packages globally, then consider one of these approaches: https://docs.npmjs.com/getting-started/fixing-npm- permissions d. Create your Gatsby Site $ cd ~/Desktop $ gatsby new wcbtn-gatsby https://github.com/indigotree/gatsbyworkshop- wc2018-starter.git $ cd ./wcbtn-gatsby $ gatsby develop
  • 29. 1. Query GraphQL for all WordPress pages Gatsby doesn't create pages automatically, we need to query all of our WordPress pages and create physical pages for them. We first need to query for the WordPress pages. Add this within gatsby-node.js to define the query.
  • 30. 2. Run the GraphQL query, and loop through the results Still inside gatsby-node.js, we need to run the GraphQL query, which will return back all of the pages that matched our query. Here we can loop over those pages ready for step 3 where we create the Gatsby pages.
  • 31. 3. Create pages with Gatsby We can use the createPage function from Gatsby to create physical pages on our site. This code can be added within the loop that we wrote in step 2..
  • 32. 4. Create the page.js page template Every page created by createPage() needs to have a template. Let's start by adding an empty template to output the page title & content. Create a file at src/templates/page.js and add the following:
  • 33. 5. Re-run the gatsby-develop command As we have now made changes with how Gatsby handles the WordPress content. We need to re run the gatsby develop command. You will first need to cancel the current process with CTRL + C and then run gatsby develop.
  • 34. 6. Check Gatsby has created the pages This should create a Gatsby page for each of our WordPress pages. If you visit http://localhost:8000/nope, which is the Gatsby dev 404 page, you should be able to see a list of all pages created by Gatbsy. Try to visit one of the pages Gatsby has created for us, such as http://localhost:8000/about where we should see our title & content from WordPress.
  • 35. 7. Improving our page.js template Update our src/templates/page.js template to include the following code:
  • 36. 8. Tell Gatsby to use our homepage template During step 3, in gatsby-node.js, we told Gatsby to create all pages using our page.js template. But as we would like our homepage to use a different template, we can add a check to see which page is being created and provide Gatsby with the correct template to use. Next, we need to remove the temporary homepage that you can find at src/pages/index.js. Simply delete this file.
  • 37. 9. Re-run the gatsby-develop command As we have now made changes with how Gatsby handles the WordPress content. We need to re run the gatsby develop command. You will first need to cancel the current process with CTRL + C and then run gatsby develop.
  • 38. 10. Next Steps Add the posts and archive • We have added news articles in the WordPress site • We have added react components in our code So you will need to: • Setup your Gatsby templates • Pull in articles through gatsby-node.js The commit which contains all of the code for the news/articles ... • https://github.com/indigotree/gatsbyworkshop- wc2018/commit/15189a701d4a48b41f6477c29b0d2c96 e701bc85
  • 39. Hosting We recommend Netlify https://www.netlify.com/ 1. Push up code to your Git repo 2. Sign up to Netlify https://app.netlify.com/signup 3. Connect Netlify with your Git Repo
  • 40. Useful Links The demo website ... https://wcbtn2018.indigotree.co.uk/ The code for the entire demo website ... https://github.com/indigotree/gatsbyworkshop-wc2018 The starter repo for the workshop ... https://github.com/indigotree/gatsbyworkshop-wc2018-starter The completed code for the workshop ... https://github.com/indigotree/gatsbyworkshop-wc2018-complete The commit which contains all of the workshop code we're asking you to add ... https://github.com/indigotree/gatsbyworkshop- wc2018/commit/12ea9c2d5c343c29460dbcc5d430c9f3ae681105 The commit which contains all of the code for the news/articles ... https://github.com/indigotree/gatsbyworkshop- wc2018/commit/15189a701d4a48b41f6477c29b0d2c96e701bc85 WordPress plugin… https://github.com/indigotree/gatsbyworkshop-wc2018-wp-plugin Gatsby documentation https://www.gatsbyjs.org/
  • 41.

Editor's Notes

  1. Indigo Tree Based in Berkhamsted Louise Towler Chris Geary
  2. Extra effort is required to optimise, crop & compresses images, generates urls etc php & mySQL required on server, can slow down site Extra effort for security
  3. Version 1 released July 2017 Gatsby handles all of the assets for you, optimises, crops, compresses, generates urls etc and puts them in the page for you es6 & es7 modern JavaScript – not implemented in browser, automatically translated or converted So can build a website that only uses static files for very fast page loads, service workers, code splitting, server side rendering, image loading and asset optimisation
  4. You get all of this without any extra work
  5. Multiple data sources WordPress is a great content editor, access and workflow Gatsby uses GraphQL to build the data. So you can collect your data from WordPress REST API, Markdown, third-party APIs Modern development practices
  6. Netlify – CDN has pages as well
  7. Everything is a component – page templates and individual parts of pages Those react components are then used by GraphQL to get data required at build time Builds static pages
  8. Our plugin adds extra WP options to the API for Gatsby to use as config - Add Yoast meta data to the API - Add ACF custom fields