The mkdocs-link-favicon plugin enables the automatic generation of a favicon before each external link. Additionally, it provides an option to configure externals link to open in a new tab. A demo can be found on my personal website.
To integrate the plugin into your documentation:
- Copy the
assetsdirectory into yourdocsfolder. - Add the following lines to your
mkdocs.ymlconfiguration file:
extra_javascript:
- assets/js/link-favicon.config.js
- assets/js/link-favicon.js
extra_css:
- assets/css/link-favicon.cssThe following providers can be used to generate favicons
- Google (default)
- DuckDuckGo
- IconHorse
You can customize icons by adding them to the assets/icons directory and specifying a mapping in the configuration file.
The openInNewWindow boolean determines whether external hyperlinks should open in a new tab.
Specific URLs for which you don't want a favicon generated, you can include them in the excludes array.
Example of the config file assets/js/link-favicon.config.js
const linkFaviconConfig =
{
provider: 'Google',
openInNewWindow: true,
iconsPath: '/assets/icons',
icons: {
'wikipedia' : 'wikipedia.svg',
'microsoft' : 'microsoft.svg',
'github' : 'github.svg'
},
excludes: [
'https://www.google.com/s2/favicons'
],
};