Skip to content

Commit

Permalink
Fix favicon path issue on non-homepage pages in Firefox
Browse files Browse the repository at this point in the history
- Fixed "favicon not found" error on non-homepage pages, particularly in Firefox.
- Problem traced to incorrect favicon path introduced in commit 58177ea.
- Updated path from absolute to relative to resolve the issue.
- Ensures favicons load correctly across all pages.

Fixes sugarlabs#507
  • Loading branch information
vidipsingh committed Jan 5, 2025
1 parent 58177ea commit 15f9065
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link id="defaultIcon1" rel="shortcut icon" href="/assets/favicon.png" />
<link id="defaultIcon1" rel="shortcut icon" href="{{ site.baseurl }}assets/favicon_06.png" />
<title>{{ page.title }}</title>
<link href="{{ site.baseurl }}/css/googleFonts.css" rel="stylesheet" type="text/css" >
<meta name="robots" content="index,follow,NOODP" />
Expand Down
18 changes: 5 additions & 13 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,11 @@ $(document).ready(function () {

var defaultIcon = document.querySelector('#defaultIcon1');
if (defaultIcon) {
// Use absolute path for favicon
var faviconPath = '/assets/favicon_' + logoID + '.png';

// Test if favicon exists before setting
var img = new Image();
img.onload = function() {
defaultIcon.href = faviconPath;
};
img.onerror = function() {
// Fallback to default favicon
defaultIcon.href = '/assets/favicon.png';
};
img.src = faviconPath;
var logoID = colorIndex + 1;
if (logoID < 10) {
logoID = "0" + logoID;
}
defaultIcon.href = 'assets/favicon_' + logoID + '.png';
}

var h = document.querySelector('.logo1').innerHTML;
Expand Down

0 comments on commit 15f9065

Please sign in to comment.