You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can use the jekyll-target-blank plugin to automatically add the attributes target="_blank" and rel="noopener noreferrer" to all external links in pages, posts and custom collections.
Doing this will involve three steps:
Update each site to use the jekyll-target-blank gem.
Update the _config.yml for each site, adding jekyll-target-blank to the plugins section.
Rebuild every site.
This will be quite painful unless we can automate these steps. We can automate step 2 by updating the update-repo-files script to modify _config.yml files. Automating steps 1 and 3 will be easier for CMS sites than for older sites. Consider the following:
We can make CMS sites use the jekyll-target-blank gem simply by updating the public isomer-jekyll gem to include it. For sites that do not use isomer-jekyll, we'll have to update their Gemfiles manually or write a script similar to update-repo-files to do it.
We can use the rebuild-sites script to rebuild all sites, but this script needs metadata that we must currently collect manually (domain name, netlify site id, and keycdn zone id). We could automate similar changes more easily in the future if we stored this metadata in a database that rebuild-sites can read. This makes sense for CMS sites, but not for older sites.
Since this change is not urgent, it seems best to automate it after all older sites are either moved out of the Isomer org or updated to use the isomer CMS. Once we can assume that all sites are on the Isomer CMS, we can automate this change and then reuse our approach when making similar updates in the future.
Finally, note that after we start using the jekyll-target-blank plugin we may still need to fix a few external links here and there. For example, the jekyll-target-blank plugin doesn't appear to affect maps_links in contact-us.md. The contact_us layout processes external links with the external_url function, which adds target="_blank" rel="noreferrer" to external links. (This is probably good enough, but we could add noopener for consistency). There may more external links that we haven't noticed yet, so we should do a thorough check.
Fulfill Lighthouse audit items by detecting external links and adding the appropriate attribute
The text was updated successfully, but these errors were encountered: