Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Creating the Menu and Footer Using Variables for the Title Tag

Kayla Evans
Kayla Evans
6,614 Points

I am working on the Shirts for Mike website (PHP Dev. Stage 2) I cannot get the icon image to work for beside of title?

The little icon that appears beside of the title of the page won't show. The Home page shows the piece of paper, and the other pages just show the browser searching thing. I don't believe this was discussed in the videos, but I can't figure out why its not working. I have all the files in the htdocs, I believe the icon would be favicon.ico. Any help would be very much appreciated.

11 Answers

Don Shipley
Don Shipley
19,488 Points

Where is your favicon.ico located? This is how my link for the ico looks in my code located in my css file. <link rel="shortcut icon" href="<?php echo BASE_URL; ?>favicon.ico"> <br> My base url is located in another php file <br> define("BASE_URL","/treehouse/PHP/project02-stage08-shirts4mike/"); define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/treehouse/PHP/project02-stage08-shirts4mike/");

Don Shipley
Don Shipley
19,488 Points

Looks like you need to include where the file is located link rel="shortcut icon" href= "foldername/favicon.ico">

Don Shipley
Don Shipley
19,488 Points

You may need to download the ico and place it into the correct directory.

Don Shipley
Don Shipley
19,488 Points

<link rel="favicon icon" href="/images/favico.ico" /> The link would need to be under <head> </head> of your html

Kayla Evans
Kayla Evans
6,614 Points

I have that file in the file htdocs inside of XAMPP. There was an error saying it was trying to connect to googleapis.com for the fonts. The page stay loading and freezes the whole page. I have to x it out because I can't click anything. In this lesson the HTML and CSS was all done for us.

Don Shipley
Don Shipley
19,488 Points

You need to make sure xampp is running otherwise your browser will not read php

Kayla Evans
Kayla Evans
6,614 Points

It still isn't working. The icon will come up on the index page now, but the others are still not working. I rebooted and restarted xampp. :(

Can we see the html and tell us where your images are located?

Kayla Evans
Kayla Evans
6,614 Points

(Header-- listed in seperate file) <html> <head> <title><?php echo $pageTitle; ?></title> <link rel="stylesheet" href="css/style.css" type="text/css"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css"> <link rel="shortcut icon" href="favicon.ico"> </head> <body>

<div class="header">

    <div class="wrapper">

        <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

        <ul class="nav">
            <li class="shirts"><a href="shirts.php">Shirts</a></li>
            <li class="contact"><a href="contact.php">Contact</a></li>
            <li class="cart"><a href="#">Shopping Cart</a></li>
        </ul>

    </div>

</div>

<div id="content">

<?php $pageTitle= "Contact Mike"; include('inc/header.php'); ?>

<div class="section page">

<h1>Contact</h1>

</div>

<?php include('inc/footer.php'); ?>


</div>

<div class="footer">

    <div class="wrapper">

        <ul>        
            <li><a href="http://twitter.com/treehouse">Twitter</a></li>
            <li><a href="https://www.facebook.com/TeamTreehouse">Facebook</a></li>
        </ul>

        <p>&copy;<?php echo date('Y'); ?> Shirts 4 Mike</p>

    </div>

</div>

</body> </html>

<?php include('inc/footer.php'); ?>

Kayla Evans
Kayla Evans
6,614 Points

This is also listed in the head...the site keeps hiding this from my post

    <link rel="stylesheet" href="css/style.css" type="text/css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css">
<link rel="shortcut icon" href="favicon.ico">

The file for favicon.ico is ---> This PC > Local Disk (C:) > xampp > htdocs I have a screen shot but I don't know how to get pics on here.

I'm thinking that Don is right about need to explicitly state the file path, funny thing about slicing things up in php is that the file paths sometimes get tricky because it's not all one file anymore. Is your favicon.ico on the same directory level as your header file/index file?

Don Shipley
Don Shipley
19,488 Points

Yes what Garrett Kucinski says is also true. This can get very tricky with the html. keeping your files all in one folder is easier. But lets say you have all your pages located in the main directory. It will look inside the same directory as your pages regardless where your header.php may be located. If you open your index.php and all your pages are located in the same directory you just need to tell which your folder for your images are located.If it were calling from your css file located in a different folder like css and calling a background you may need to go up one directory ../images/imageFile.

Kayla Evans
Kayla Evans
6,614 Points

I finally got the page to load the icon. Thing is I will have the continuous load sign, then I press the X to stop the loading and it will finally show the icon. Not sure what it is trying to load, but I'm just happy it shows up now. Just if you guys are curious, I moved the favicon into the img folder then changed the extension in the head. Worked great.