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

Add structured data example #2129

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

jmshea
Copy link
Contributor

@jmshea jmshea commented Mar 5, 2024

Structured data helps machines (particularly Google Search) better understand your pages' contents. Here I show how to add some of the most basic structured data (site name and search path) by adding a small Javascript+JSON snipppet in the _static directory.

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.30%. Comparing base (30afdb7) to head (bbbbbaf).
Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2129   +/-   ##
=======================================
  Coverage   91.30%   91.30%           
=======================================
  Files           7        7           
  Lines         690      690           
=======================================
  Hits          630      630           
  Misses         60       60           
Flag Coverage Δ
pytests 91.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agoose77
Copy link
Collaborator

agoose77 commented Mar 5, 2024

Thanks for this contribution @jmshea! I see that this is using JSON-LD to embed structured information to a built site. Would you be happy to add more context to this, briefly, e.g.

etc.

I didn't realise that this was already exposed to site authors, how exciting!

@jmshea
Copy link
Contributor Author

jmshea commented Mar 5, 2024

@agoose77 Thank you for the quick feedback. Yes, I can do that.

@jmshea
Copy link
Contributor Author

jmshea commented Mar 5, 2024

@agoose77 I have updated the discussion per your suggestions. See what you think.

docs/advanced/html.md Outdated Show resolved Hide resolved
@jmshea
Copy link
Contributor Author

jmshea commented Mar 5, 2024

@agoose77 Thanks for revising and fixing my typo (original "directly" was supposed to "directory"). Let me know if there is anything else I need to do.

@agoose77
Copy link
Collaborator

@jmshea do you know whether crawlers like Google wait for the JS to load before inspecting the structured metadata? i.e., does dynamically appending to the DOM like this work in practice?

@jmshea
Copy link
Contributor Author

jmshea commented Mar 14, 2024

@agoose77 Yes, this is explicitly mentioned in the Google docs, and I have tested this on my own sites already, and it works.

@jmshea
Copy link
Contributor Author

jmshea commented Mar 15, 2024

To see that this works, you can go to Google's Rich Results Test (https://search.google.com/test/rich-results) and put in my book's website: https://www.fdsp.net

This suggested addition to the JupyterBooks docs is based on how I got this working on my own site.

@jmshea
Copy link
Contributor Author

jmshea commented Apr 9, 2024

@agoose77 Please let me know if any other updates are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants