Skip to content

Don't open external links in a new tab#22

Closed
jukent wants to merge 2 commits intoProjectPythia:mainfrom
jukent:links
Closed

Don't open external links in a new tab#22
jukent wants to merge 2 commits intoProjectPythia:mainfrom
jukent:links

Conversation

@jukent
Copy link
Contributor

@jukent jukent commented Feb 24, 2026

Expected user input to avoid external links opening in a new tab per MyST parser documentation. MyST does not support all MyST parser configuration settings, so this currently doeesn't work (tried adding it to a specific Cookbook just to test).

The closest I've found so far is url-entries documentation:

- url: 'https://google.com'
  title: Google
  open_in_same_tab: true

I can at least add this setting to the navbar links, but adding it to every link throughout the project is tedious. @agoose77 do you know if there will be any support for a global option to change the default behavior?

@jukent
Copy link
Contributor Author

jukent commented Feb 24, 2026

Not suggesting we do this as it slows down our website response times, but sample code to overwrite the behavior:

site:
  options:
    html_head: |
      <script>
        document.addEventListener('DOMContentLoaded', function() {
          document.querySelectorAll('a[target="_blank"]').forEach(function(link) {
            link.removeAttribute('target');
          });
        });
      </script>

@jukent
Copy link
Contributor Author

jukent commented Mar 3, 2026

Closing in favor of #25 specifying open_in_new_tab as False may still be possible if we aren't catching foundations.projectpythia.org in the wildcard.

@jukent jukent closed this Mar 3, 2026
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.

1 participant