Skip to content
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

[docs] Add advanced tutorials for SEO and social sharing cards #20964

Merged
merged 26 commits into from
Mar 4, 2020

Conversation

FlorianDr
Copy link

@FlorianDr FlorianDr commented Jan 28, 2020

Description

This is about moving the initial blog post by @DSchau into a new advanced tutorial and link it in the reference guide on the SEO page.

Related Issues

Fixes #14125

@FlorianDr FlorianDr changed the title [docs] Add tutorials for SEO and social sharing cards [docs] Add advanced tutorials for SEO and social sharing cards Jan 28, 2020
@FlorianDr FlorianDr marked this pull request as ready for review January 28, 2020 20:07
@FlorianDr FlorianDr requested review from a team as code owners January 28, 2020 20:07
@DSchau
Copy link
Contributor

DSchau commented Jan 29, 2020

Cool 😎 Thanks for doing this!

I'll defer to @gatsbyjs/learning for the content review 👍

@AishaBlake AishaBlake self-assigned this Jan 31, 2020
Copy link

@AishaBlake AishaBlake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for putting in the work to move this over from Dustin's original post and for your patience while I was away for Gatsby Days/Gathering last week!

This looks like a ton of comments but most are fairly straightforward suggestions. I'm particularly interested in making some improvements to the images' alt text. Someone from the Learning team will also walk through this tutorial to verify everything still works as expected!

title: Search Engine Optimization (SEO) and Social Sharing Cards with Gatsby
---

Perhaps you've even been approached by an SEO _expert_ who can maximize your revenue and page views just by following these **Three Simple Tricks**! However, relatively few make the concerted effort to implement SEO in their web app. This tutorial will share some of the ins and outs of SEO and how you can implement common, simple SEO patterns in your Gatsby web app, today. By the end of this post you'll know how to do the following:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Perhaps you've even been approached by an SEO _expert_ who can maximize your revenue and page views just by following these **Three Simple Tricks**! However, relatively few make the concerted effort to implement SEO in their web app. This tutorial will share some of the ins and outs of SEO and how you can implement common, simple SEO patterns in your Gatsby web app, today. By the end of this post you'll know how to do the following:
Perhaps you've been approached by an SEO _expert_ who can maximize your revenue and page views just by following these **Three Simple Tricks**! Relatively few people make the concerted effort to implement SEO in their web app. This tutorial will share some of the ins and outs of SEO and how you can implement common, simple SEO patterns in your Gatsby web app, today. By the end of this post you'll know how to do the following:

Looks like the very beginning of the original text is missing. I would either add it back in or reword this along the lines of what I've suggested.


## Implementation

The core technology powering SEO is the humble, ubiquitiuous `meta` tag along with common tags like `title`. You've probably seen something like the below:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this take into account the feedback from Andrew Welch? It looks like Dustin didn't get to address all of it in his original PR. I know the ask was only to slightly modify Dustin's post, so I won't let this hold up merging.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the pointer. I will have a look at the feedback and try to incorporate it.

/>
```

These are the _bare minimum_ requirements that should be implemented within an application's `head` tags for simple and basic SEO. However -- the following describes a powerful combo of content rendered at _build time_ powered by Gatsby and GraphQL. Let's dive in.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These are the _bare minimum_ requirements that should be implemented within an application's `head` tags for simple and basic SEO. However -- the following describes a powerful combo of content rendered at _build time_ powered by Gatsby and GraphQL. Let's dive in.
These are the _bare minimum_ requirements that should be implemented within an application's `head` tags for basic SEO. However, the following describes a powerful combo of content rendered at _build time_ powered by Gatsby and GraphQL. Let's dive in.

Please remove any instances of words like "easy" or "simple". We try to make sure the docs are as friendly as we can make them and avoid making too many assumptions about readers' knowledge.


## Gatsby + GraphQL

GraphQL is a crucial feature enabled via Gatsby (note: you don't [_have_ to use GraphQL with Gatsby][unstructured-data]). Leveraging GraphQL to query your indexable content--wherever it lives (at build time!)--is one of the most powerful and flexible techniques enabled via Gatsby. Let's briefly look at the implemention of an extensible and flexible SEO component.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GraphQL is a crucial feature enabled via Gatsby (note: you don't [_have_ to use GraphQL with Gatsby][unstructured-data]). Leveraging GraphQL to query your indexable content--wherever it lives (at build time!)--is one of the most powerful and flexible techniques enabled via Gatsby. Let's briefly look at the implemention of an extensible and flexible SEO component.
GraphQL is a crucial feature enabled via Gatsby (note: you don't [_have_ to use GraphQL with Gatsby][unstructured-data]). Leveraging GraphQL to query your indexable content--wherever it lives (at build time!)--is one of the most powerful and flexible techniques enabled via Gatsby. The following sections are a brief look at the implementation of an extensible and flexible SEO component.

Try to avoid (or update) any instances of "we" or "let's" and prefer "you" as the pronoun.


### `StaticQuery`

Gatsby distinguishes between page-level queries and component queries. The former can use page GraphQL queries while the latter can use a new in Gatsby v2 feature called [`StaticQuery`][gatsby-static-query]. A StaticQuery will be parsed, evaluated, and injected at _build time_ into the component that is requesting the data, allowing to fall back to sane defaults, while also providing an extensible, reusable component.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Gatsby distinguishes between page-level queries and component queries. The former can use page GraphQL queries while the latter can use a new in Gatsby v2 feature called [`StaticQuery`][gatsby-static-query]. A StaticQuery will be parsed, evaluated, and injected at _build time_ into the component that is requesting the data, allowing to fall back to sane defaults, while also providing an extensible, reusable component.
Gatsby distinguishes between page-level queries and component queries. The former can use page GraphQL queries while the latter can use [`StaticQuery`][gatsby-static-query]. A StaticQuery will be parsed, evaluated, and injected at _build time_ into the component that is requesting the data, allowing it to fall back to reasonable defaults, while also providing an extensible, reusable component.

I think we should replace the word "sane" here. We don't have a specific guideline that covers it but there's room to make a kinder choice. Also, StaticQuery (and v2) are no longer new!


Feel free to add whatever, or perhaps use this _very pertinent_ image:

![Sample Image](./images/seo.jpg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Sample Image](./images/seo.jpg)
![Sample Image](./images/seo.jpg)

If you choose to maintain the sentence immediately preceding this image, I suggest making the alt text more specific. Anyone who can't see the image won't get the joke!


![Sample Image](./images/seo.jpg)

the image will need to be located at `content/blog/2019-01-04-hello-world-seo/images/featured.jpg`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the image will need to be located at `content/blog/2019-01-04-hello-world-seo/images/featured.jpg`
The image will need to be located at `content/blog/2019-01-04-hello-world-seo/images/featured.jpg`.


To learn more about these validations, check out how to _validate_ SEO with the following tools from [Google][google-validation], [Twitter][twitter-validation], and [Facebook][facebook-validation].

These SEO resources outlined in this tutorial aren't _only_ a best practice, they're also a best practice enabled, by default. Available **today** in `gatsby-starter-default`, simply use:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These SEO resources outlined in this tutorial aren't _only_ a best practice, they're also a best practice enabled, by default. Available **today** in `gatsby-starter-default`, simply use:
The SEO resources outlined in this tutorial aren't _only_ a best practice, they're also a best practice enabled by default. Available **today** in `gatsby-starter-default`, use:

These SEO resources outlined in this tutorial aren't _only_ a best practice, they're also a best practice enabled, by default. Available **today** in `gatsby-starter-default`, simply use:

```shell
npx gatsby new my-new-gatsby-app

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
npx gatsby new my-new-gatsby-app
npm gatsby new my-new-gatsby-app

This is mostly for consistency with other docs.

@AishaBlake
Copy link

Hi, @FlorianDr! Checking in on this and to see if there's anything I can help with or clarify.

@FlorianDr
Copy link
Author

@AishaBlake thank you for offering your help. I started implementing your feedback, but I haven't brought it to next review yet. I will keep you posted about it. Let me know, if it's urgent to finish it ASAP.

@wardpeet wardpeet added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Feb 24, 2020
@FlorianDr
Copy link
Author

@AishaBlake I would be keen to hear your feedback again :) Sorry for the delay with this matter.

@AishaBlake
Copy link

AishaBlake commented Mar 3, 2020

Thanks, @FlorianDr! I made some quick edits but realized I missed a larger update. The code samples should be updated to reflect the current versions. If we want folks to be able to follow along, we ought to start the tutorial off at each file's starting point in the default starter. (For example, we now use the useStaticQuery hook and give devs more meta tags out of the box in seo.js than is indicated here.)

It would also be good to point out the compatibility notes on gatsby-plugin-react-helmet's page.

@AishaBlake
Copy link

The last thing I think this needs is to close the loop and show how'd you'd add a featured image, then what that would look like when linked on social media. This feels outside the scope of this PR, though, so I'll make an issue for it!

Copy link

@AishaBlake AishaBlake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlorianDr I started to do this in suggestions and it was a bit much. Let me know what you think of that last commit. If you're happy with it, I'm ready to merge!

@AishaBlake
Copy link

I'm actually going to go ahead and merge to keep this moving. Thank you so, so much for contributing, @FlorianDr. Really happy to finally get this content somewhere live!

@AishaBlake AishaBlake merged commit fccab72 into gatsbyjs:master Mar 4, 2020
@gatsbot
Copy link

gatsbot bot commented Mar 4, 2020

Holy buckets, @FlorianDr — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@FlorianDr
Copy link
Author

@AishaBlake Thank you so much for helping me getting this over the finish line. I learned so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs] Add more details on implementing SEO techniques in Gatsby
4 participants