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 opengraph tags #2717

Merged
merged 2 commits into from
May 27, 2022
Merged

Add opengraph tags #2717

merged 2 commits into from
May 27, 2022

Conversation

manics
Copy link
Member

@manics manics commented May 22, 2022

Jupyter readthedocs sites are often referenced on the Jupyter Discourse. The lack of Open Graph tags means link previews aren't useful, e.g. in the compose mode
image

This uses sphinxext-opengraph as suggested by @choldgraf in pydata/pydata-sphinx-theme#664

@consideRatio
Copy link
Member

consideRatio commented May 23, 2022

@manics wieee nice!! I observe it to not yet function though based on the PR preview. I did this on discourse.jupyter.org:

image

It sais it fails to find image and description. But, I see the following though... Hmmm...

image


  • I think we should set ogp_site_url to https://z2jh.jupyter.org to avoid use of the longer https://zero-to-jupyterhub.readthedocs.io/
  • I think we should explicitly set ogp_image to https://z2jh.jupyter.org/en/latest/_static/logo.png
    image
  • I think we should set the ogp_use_first_image option to true

@choldgraf
Copy link
Member

agree w/ @consideRatio - we need to add a bit of configuration to get the base url right etc, and then the link metadata / logo should show up properly

@manics
Copy link
Member Author

manics commented May 27, 2022

I've added some tags for og:image. I didn't change the site URL because according to the docs RTD will set it automatically, and it may need to include the site prefix en/latest/ which may cause problems with multiple versions of the docs.

https://cards-dev.twitter.com/validator refuses to load the rendered RTD pages because bots are blocked by robots.txt, maybe Discourse does the same?

@manics manics marked this pull request as ready for review May 27, 2022 12:22
@manics manics changed the title WIP: Add opengraph tags Add opengraph tags May 27, 2022
@manics
Copy link
Member Author

manics commented May 27, 2022

The other option mentioned in pydata/pydata-sphinx-theme#664 (comment)

define a jupyterhub-sphinx-theme that pre-configures some things for all of our repositories. For example, we could automatically add a link to our Discourse forum, Jupyter home page, etc (and each repository could then additionally configure it on top of that).

If we can include

ogp_image = "_static/logo.png"
ogp_use_first_image = True

in jupyterhub-sphinx-theme and all JupyterHub RTD sites have _static/logo.png this would provide a drop-in zero config theme. We could also pin the version of pydata-sphinx-theme exactly but leave jupyterhub-sphinx-theme unpinned in all repos, so we have full central control over the base theme if there are pydata-sphinx-theme bugs.

@consideRatio
Copy link
Member

@manics I think you are right!

See the difference between the preview robots.txt https://zero-to-jupyterhub.org.readthedocs.build/robots.txt vs the production robots.txt https://z2jh.jupyter.org/robots.txt. robots.txt is blocked in the preview setting, but not for RTD production pages not meant for preview.

It makes sense, they should stop scrapers etc from finding preview pages. I think things may work if we merge this :)

@consideRatio consideRatio merged commit ecafaa5 into jupyterhub:main May 27, 2022
@choldgraf
Copy link
Member

choldgraf commented May 27, 2022

@manics if we define a jupyterhub theme we could also consider defining some extensions that are automatically installed in all of our repositories (e.g. sphinx-copybutton) or some theme styles to standardize (e.g. the primary color could be jupyter orange). Another option would be to use a single-page theme like the Sphinx Book Theme and then define a topbar in the jupyterhub theme that is shared between all projects. This is what the Dask project does as well as the 2i2c docs. I actually have a PR open in the book theme to make this easier to do, would love comments if you think it'd be helpful: executablebooks/sphinx-book-theme#559

@consideRatio
Copy link
Member

image

Things seem to work overall, there is an issue with a reference to favicon.ico but other than that, things work!

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

Successfully merging this pull request may close these issues.

3 participants