Skip to content

when using a url: entry in the TOC: how to open it in a separate tab/window #1173

Answered by agoose77
parmentelat asked this question in Q&A
Discussion options

You must be logged in to vote

The answer right now is that you can use custom JS to set the target on these pages:

document.querySelectorAll("nav a.reference.external").forEach(node => {node.target = "_blank"})

Then you can load this JS on each page: https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/static_assets.html#define-a-list-of-assets-in-conf-py

For JupyterBook, you would set this in your _config.yml e.g. https://jupyterbook.org/en/stable/advanced/html.html#use-plausible-analytics.

For MyST-MD, we don't yet support external URLs in the main table of contents, though it is something that we're thinking about: jupyter-book/mystmd#1188

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@parmentelat
Comment options

Answer selected by parmentelat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants