Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a favicon to a Pelican blog?

I am creating a static site with Pelican and I'm confused about how to add a favicon to it.

I've seen in the documentation that:

You can also use the EXTRA_PATH_METADATA mechanism to place a favicon.ico or robots.txt at the root of any site.

I don't know where to put my favicon.ico file and what to specify in the EXTRA_PATH_METADATA setting (if this is really the setting that should be used).

like image 592
Paulo MiraMor Avatar asked Jul 07 '15 13:07

Paulo MiraMor


2 Answers

In my pelicanconf.py, I have:

STATIC_PATHS = [
    'images',
    'extra',  # this
]
EXTRA_PATH_METADATA = {
    'extra/custom.css': {'path': 'custom.css'},
    'extra/robots.txt': {'path': 'robots.txt'},
    'extra/favicon.ico': {'path': 'favicon.ico'},  # and this
    'extra/CNAME': {'path': 'CNAME'},
    'extra/LICENSE': {'path': 'LICENSE'},
    'extra/README': {'path': 'README'},
}

The structure for these extra files is then:

/content
    /extra
        favicon.ico
        robots.txt

See the documentation, which shows a similar layout.

like image 50
jonrsharpe Avatar answered Sep 20 '22 17:09

jonrsharpe


The official way @jonrsharpe described doesn't work for my page. I don't know why, it should.

I decided to put the favicon.ico in the image folder and to insert a link in base.html to get it work:

<link rel="shortcut icon" href="{{ SITEURL }}/images/favicon.ico?v=2" />
like image 36
flowerflower Avatar answered Sep 18 '22 17:09

flowerflower