jupyter-book
jupyter-book copied to clipboard
Add structured data example
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.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 91.30%. Comparing base (
9e21d5e) to head (8367396). Report is 24 commits behind head on master.
:exclamation: Current head 8367396 differs from pull request most recent head 3a14877
Please upload reports for the commit 3a14877 to get more accurate results.
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.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
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.
- what is "structured data"? mention JSON-LD as an example
- who uses it? https://developers.google.com/search/docs/appearance/structured-data/search-gallery
etc.
I didn't realise that this was already exposed to site authors, how exciting!
@agoose77 Thank you for the quick feedback. Yes, I can do that.
@agoose77 I have updated the discussion per your suggestions. See what you think.
@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.
@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?
@agoose77 Yes, this is explicitly mentioned in the Google docs, and I have tested this on my own sites already, and it works.
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.
@agoose77 Please let me know if any other updates are needed.
Shall I close this? I thought this might be useful info to others, but maybe it is just too aligned with Google?
@jmshea I was being too slow and deliberating on this, but we don't have the bandwidth to worry about being so cautious. Thank you for your time on this, it's a great addition!