jupyter-book icon indicating copy to clipboard operation
jupyter-book copied to clipboard

Add structured data example

Open jmshea opened this issue 1 year ago • 9 comments

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.

jmshea avatar Mar 05 '24 14:03 jmshea

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.

codecov[bot] avatar Mar 05 '24 14:03 codecov[bot]

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 avatar Mar 05 '24 15:03 agoose77

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

jmshea avatar Mar 05 '24 15:03 jmshea

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

jmshea avatar Mar 05 '24 15:03 jmshea

@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 avatar Mar 05 '24 15:03 jmshea

@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 avatar Mar 11 '24 09:03 agoose77

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

jmshea avatar Mar 14 '24 12:03 jmshea

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 avatar Mar 15 '24 12:03 jmshea

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

jmshea avatar Apr 09 '24 14:04 jmshea

Shall I close this? I thought this might be useful info to others, but maybe it is just too aligned with Google?

jmshea avatar Sep 30 '24 13:09 jmshea

@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!

agoose77 avatar Oct 02 '24 19:10 agoose77