giansi / gravstrap-theme

Gravstrap Theme helps you to start a new Grav CMS site with Bootstrap support and several ready to use modules. It is also perfect to start a new Bootstrap custom theme, to create your unique design.
MIT License
7 stars 12 forks source link

editing favicon image #12

Open 4evermaat opened 8 years ago

4evermaat commented 8 years ago

I need to know how to edit the favicon image for 1) entire theme and also override for 2) individual pages or folders.

I have one possible solution here but I could not find it there for gravstrap theme

4evermaat commented 8 years ago

we ended up editing the user/themes/gravstrap/``base.html.twig . There is a line here: <link rel="icon" type="image/png" href="{{ theme_url }}/images/favicon.png" /> or <link rel="icon" type="image/png" href="{{ url('theme://images/favicon.png', true) }}" />

You replace it with the following code:

{% if page.header.custom_favicon %}
<link rel="shortcut icon" type="image/x-icon" href="{{ url('user/pages/images/' ~ page.header.custom_favicon, true) }} " />
{% else %}
<link rel="shortcut icon" type="image/x-icon" href="{{ url('user/pages/images/favicon.ico', true) }}" />
{% endif %}

You create a new folder in the /user/pages/images and stick all of your favicons there, you can use any file format the browser accepts, including .ico (usually you use .ico or .png for favicon images) Then if you want to use a custom favicon, on the frontmatter of the page you put this parameter

custom_favicon: whatever.ico

If the custom_favicon header variable is not there, it will use the default favicon.ico.

You can use theme://images/ if you prefer to keep everything in the images folder

giansi commented 8 years ago

Could you make a PR for that?

4evermaat commented 7 years ago

I added a PR for it here: https://github.com/giansi/gravstrap-theme/pull/29