Correct way to place the favicon in Sage 9

Hi!
I recently did a small guide to myself for future projects. Use it to add the favicon for the site and for the admin backend if you want:

  • generate front favicon with realfavicongenerator.net using @asset('images/favicon/
  • add returned markup in head.blade.php and add the ') at the end of assets
  • add the folder in images/favicon
  • generate admin favicon with realfavicongenerator.net using ’ . asset_path('images/favicon/favicon-admin/
  • add and adapt returned markup to admin.php
    // Custom FAVICON for admin
    function cc_admin_add_favicon() {
        // close asset paths with ') . '
        echo
        '...';
    }
    
    // Now, just make sure that function runs when you're on the login page and admin pages
    add_action('login_head', __NAMESPACE__.'\\cc_admin_add_favicon');
    add_action('admin_head', __NAMESPACE__.'\\cc_admin_add_favicon');
    
3 Likes