LAPS

How to setup a favicon for my PW website?

Recommended Posts

I tried to do some search, but I did not find how to setup a favicon for my PW website e.g. where to put favicon file(s)?

Share this post


Link to post
Share on other sites

@kongondo I read the linked answer, but what is the webroot in PW? I mean, what is the directory (e.g. /site, /wire) where I have to put my favicon file(s)?

Share this post


Link to post
Share on other sites

It's the folder that /site/ and /wire/ live in; the one where index.php and .htaccess are (in a standard install).

  • Like 1

Share this post


Link to post
Share on other sites

@DaveP I tried to put the favicon.ico file in /, /site, /wire and others directories, as well as refresh both PW and browser cache, but it does not work. I also added the link code in the <head> tag of my template file, as follows:

<link rel="icon" type="image/x-icon" href="favicon.ico">

Share this post


Link to post
Share on other sites
1 hour ago, LAPS said:

but what is the webroot in PW?

What @DaveP said...For example:

 

/var/www/html/site

/var/www/html/wire

/var/www/html/favicon.ico

/var/www/html/.htaccess

 

Edited by kongondo
  • Like 1

Share this post


Link to post
Share on other sites

This code should help you get to the wire directory:

<link rel="icon" type="image/x-icon" href="<?php echo $config->urls->root ?>wire/favicon.ico">


But I prefer to add in the directory of my template files in which I change the path to (templates/):

<link rel="icon" type="image/x-icon" href="<?php echo $config->urls->templates ?>assets/img/favicon.ico">


Here you can read more about $config:
https://processwire.com/api/variables/config/

  • Like 1

Share this post


Link to post
Share on other sites

I usually go by @rafaoski's approach.

I first go to http://www.favicomatic.com/, upload a 500x500 image to generate a full icon pack.

Then I place the icons in their own folder inside the templates folder. Usually /site/templates/img/favicon/

Favicomatic gives you a rather large HTML snippet. Slap that on your template, and on each line that points to a file, you'll have to fix the url, like so:

<link rel="icon" type="image/x-icon" href="<?= $config->urls->templates ?>img/favicon/favicon.ico">

 

  • Like 6

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.