diff --git a/_includes/head.html b/_includes/head.html index f71e7ea5b1e2261e34f5c52b6f7e083b8ffe285d..5a6c877704b97a95dbae47e2296a3a10e2d6bb09 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -29,6 +29,15 @@ <script src="{{ '/assets/js/just-the-docs.js' | relative_url }}"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> + + {% for file in site.static_files %} + {% if file.path == site.favicon_ico or file.path == '/favicon.ico' %} + {% assign favicon = true %} + {% endif %} + {% endfor %} + {% if favicon %} + <link rel="icon" href="{{ site.favicon_ico | default: '/favicon.ico' | relative_url }}" type="image/x-icon"> + {% endif %} {% seo %} diff --git a/_includes/head_custom.html b/_includes/head_custom.html index c485d4c22e85fadd3da3d25092c1312aa502e615..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/_includes/head_custom.html +++ b/_includes/head_custom.html @@ -1 +0,0 @@ -<link rel="shortcut icon" href="{{ 'favicon.ico' | relative_url }}" type="image/x-icon"> diff --git a/docs/configuration.md b/docs/configuration.md index 6892ba44c998b763db7dd280a340302a410542f3..d7ff5de33001a82f0ae28f9d014faccd4ac578d0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -27,6 +27,15 @@ View this site's [\_config.yml](https://github.com/just-the-docs/just-the-docs/t logo: "/assets/images/just-the-docs.png" ``` +## Site favicon + +```yaml +# Set a path/url to a favicon that will be displayed by the browser +favicon_ico: "/assets/images/favicon.ico" +``` + +If the path to your favicon is `/favicon.ico`, you can leave `favicon_ico` unset. + ## Search ```yaml diff --git a/docs/customization.md b/docs/customization.md index ca3cfecb2719dd3969db4d828acc6df60fb30af2..67070ae9cee7ea9317058cef5fd0d5fe96d8a8f3 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -167,34 +167,13 @@ The (optional) `text-delta` class makes the heading appear as **Contents**{:.tex This content appears at the bottom of every page's main content. More info for this include can be found in the [Configuration - Footer content]({{ site.baseurl }}{% link docs/configuration.md %}#footer-content). -### Custom Head and Favicon +### Custom Head `_includes/head_custom.html` Any HTML added to this file will be inserted before the closing `<head>` tag. This might include additional `<meta>`, `<link>`, or `<script>` tags. -Note that by default, this file has the following contents: - -{% raw %} - -```html -<link rel="shortcut icon" href="{{ 'favicon.ico' | relative_url }}" type="image/x-icon"> -``` -{% endraw %} - -#### Example: Custom Favicon -{: .no_toc } - -To add a custom favicon, create `_includes/head_custom.html` and add: - -{% raw %} - -```html -<link rel="shortcut icon" href="{{ 'favicon.ico' | relative_url }}" type="image/x-icon"> -``` -{% endraw %} - -If *no favicon* is desired, one needs to have a *blank* `_includes/head_custom.html`. +The `<head>` tag automatically includes a link to an existing favicon if you set `favicon_ico` to the corresponding path in your configuration, or if the path to the favicon is `/favicon.ico`. ### Custom Header