Skip to content

Commit

Permalink
Added the target-blank plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Dean Wampler <dean.wampler@ibm.com>
  • Loading branch information
deanwampler committed Nov 16, 2024
1 parent 29e2212 commit 11fb014
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions GITHUB_PAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ For internal cross-references, use the conventional `[title]({{site.baseurl}}/re
> [!WARNING]
> the `{{site.baseurl}}/` prefix is _essential_, because this _prefix_ will be different for local execution vs. published serving.
For external links, add a `target` tag using the following syntax, which works for GitHub Markdown and GitHub Pages.
For external links (those that start with `http` or `https`), we use the [`jekyll-target-blank` plugin](https://github.com/keithmifsud/jekyll-target-blank) to automatically open them in a new browser tab or window. _Relative_ links within the site are opened in the same tab.

This plugin effectively adds `target="_blank"` to every anchor tag, i.e., `<a href="" target="_blank">...</a>`. However, this means that if users click on a lot of external links to see all of them, they will be "stacked" in the history of one browser tab. Therefore, you may consider adding explicit targets yourself. You can do this using the following syntax:

```markdown
[title]({{site.baseurl}}/relative_URL){:target="label"}
[`jekyll-target-blank` plugin](https://github.com/keithmifsud/jekyll-target-blank){:target="arbitrary_name"}
```

The `label` value is arbitrary; use whatever you want. While adding targets is a little more tedious to type, it is usually better for users so they don't lose their place in the document. Also, [our stylesheet](https://github.com/The-AI-Alliance/open-trusted-data-initiative/blob/main/docs/_includes/css/custom.scss.liquid) is configured to put the little up-and-to-the-right arrows after every link that isn't relative, i.e., links that start with `http` or `https`. This provides a visual clue that a new tab will be opened.
Furthermore, as a visual clue to the user, [our stylesheet](https://github.com/The-AI-Alliance/REPO_NAME/blob/main/docs/_includes/css/custom.scss.liquid) is configured to put little up-and-to-the-right arrows after every external link. This provides a visual clue that a new tab will be opened.

### Emojis

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ gem "liquid", ">= 4.0.4"

# No longer included in Ruby as of 3.4
gem "csv"

# Target blank automatically opens all links in a new window.
gem 'jekyll-target-blank'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ view-pages::
view-local:: setup-jekyll run-jekyll

# Passing --baseurl '' allows us to use `localhost:4000` rather than require
# `localhost:4000/The-AI-Alliance/trust-safety-user-guide` when -ping locally.
# `localhost:4000/The-AI-Alliance/trust-safety-user-guide` when running locally.
run-jekyll: clean
@echo
@echo "Once you see the http://127.0.0.1:${JEKYLL_PORT}/ URL printed, open it with command+click..."
Expand Down
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ show_contribute_dataset_button: true

plugins:
- jekyll-seo-tag
- jekyll-target-blank
- jemoji

kramdown:
Expand Down

0 comments on commit 11fb014

Please sign in to comment.