How to add a favicon to a Pelican blog? How to add a favicon to a Pelican blog? python python

How to add a favicon to a Pelican blog?


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.


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" />


I used the technique outlined on the Pelican Wiki: https://github.com/getpelican/pelican/wiki/Tips-n-Tricks#copying-faviconrobotstxt

Repeating here in case that page disappears:

  • create a directory beside your content dir, and put all your favicon items there.
  • in your Makefile, add if test -d $(BASEDIR)/extra; then cp $(BASEDIR)/extra/* $(OUTPUTDIR)/; fi to any spots that build the site (ex publish, html, etc)

Now when you build the site, everything in extra/ will get copied to the root of /output.