04 Formatting links - harvardinformatics/informatics-website GitHub Wiki

For clarity and consistency, I have started formatting external and download links with icons. External links now also open in new tabs. Here is a summary of how to format these links.

External links - Markdown

Icon

External links are those to any page outside of our informatics.fas.harvard.edu domain. They are now indicated with an icon link-external-24.

The MkDocs shortcut string (see Images and Icons) for this icon is :octicons-link-external-24:.

Opening in a new tab

To get a MkDocs link to open in a new tab, add the following after it:

{:target="_blank"}

Example

To put this all together, external links should always be formatted as follows:

[link text to appear on the page :octicons-link-external-24:](url){:target="_blank"}

Opening in a new tab from an HTML template

Recall that some of our pages (e.g. the homepage, the Resources page) use HTML templates and are processed with Python when the site is built. Python understands anything in curly brackets in a string template as something that needs to be formatted. As such, including {:target="_blank"} will make the script break and the site unable to be built.

Instead, you must escape the curly brackets with an extra pair of curly brackets: {{:target="_blank"}}

So, when editing templates and including an external link, it should be formatted as:

[link text to appear on the page :octicons-link-external-24:](url){{:target="_blank"}}

External links - HTML

In some instances (e.g. the Software page), lines are enclosed in HTML. In this case, the icon shortcut and Markdown syntax won't work. Instead, I have added a custom CSS class for the icon. To use this, links should be formatted as follows:

<a href="<url>" target="_blank">link text to appear on the page <span class="icon-external"></span></a>

Download links - markdown

Similarly, links that download content (e.g. workshop data) should be indicated with an icon download-24

The MkDocs shortcut string (see Images and Icons) for this icon is :octicons-download-24:, and links should be written as:

[link text to appear on the page :octicons-download-24:](url)

{:target="_blank"} for a new tab should not be necessary for downloading data files, but may be necessary for pdfs or slides.

Download links - HTML

I have not implemented a custom CSS class for the download icon, but can whenever it is needed.

Other link icons

I have also occasionally used an icon for links that are internal but open in a new tab, and an icon for internal links on buttons, but these are mostly done as needed.

Link icon summary

Link type Icon shortcut string
External :octicons-link-external-24:
Download :octicons-download-24:
Internal in new tab :material-arrow-top-right:
Internal on button :material-arrow-right:
⚠️ **GitHub.com Fallback** ⚠️