Open the header's external links in a new tab - #132
Open
eastagiletracker wants to merge 1 commit into
Open
Conversation
The social icons in the header come from _data/socials.yml, which listed the outside urls under href, so navigation.html rendered them with no target and they replaced the current page instead of opening alongside it. Split the data file into href for internal links and external for outside urls, and have the include add target="_blank" rel="noopener" whenever the url is absolute, so entries added under either key keep behaving correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes making the site header's external links truly external, so the social icons rendered on every page open in a new tab instead of replacing the page the reader is on (part of #99). We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/195. You can sign in with your GitHub ID to claim ownership of the project.
What changed and why
Issue #99 reports that outside links in the site chrome load in the same window, and asks for the other occurrences of the same behaviour to be found and fixed. The remaining one is the social bar:
_includes/navigation.htmlrenders it straight from_data/socials.yml, and that file lists YouTube, Slack, Reddit, Twitter, Facebook and LinkedIn underhref— the key the include treats as an internal link — so those six anchors go out with notarget. Because the include is pulled in by_layouts/default.htmland_layouts/archive.html, it is on every page of the site, not just one, and clicking any of the icons drops the visitor out of bsidessf.org.Reproduced on
mainatc70feae, and the same markup is live on the deployed site right now:The change follows the convention proposed in the issue comments —
hreffor internal links,externalfor outside urls — so_data/socials.ymlnow declares its six outside urls underexternal, and Graphic Recordings stays onhrefas an internal link. In_includes/navigation.htmlthe socials loop resolves either key and addstarget="_blank" rel="noopener"whenever the resulting url is absolute, which means an entry added later under the oldhrefspelling still opens in a new tab rather than quietly regressing. The two nav anchors that already usedexternalalso pick uprel="noopener", sincetarget="_blank"alone hands the opened tab a reference back to the site.Verified by building the whole site before and after and diffing the generated trees: the only difference anywhere is the added attributes — 686 anchors across 98 generated pages — with every other byte identical, and the internal Graphic Recordings link deliberately unchanged.
I also rebuilt with a temporary entry declared the old way (
href: "https://infosec.exchange/@bsidessf", matching the commented-out Mastodon line) to confirm the fallback path: it renders with the new tab attributes, whilehref: "/news"renders without them.Scope note, since the issue says "fix all of them": this covers everything the templates and data files generate, which is the site chrome on every page. A handful of hand-written links inside page copy (
volunteer.md,qna.md,privacy.mdand friends) still lacktarget, and the frozen year snapshots under_archives/are untouched on purpose. Happy to follow up on the page copy if you want it in the same style — I left it out here because those files change often and it seemed better not to collide with edits in flight.How this was managed
The work was tracked on a board imported from this repository's own issues and pull requests (131 stories, 3 labels): the story for this change is Make all external links in site truly external, on the board at https://eastagiletracker.com/projects/195.
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com