Site logo

Archived topic

Child theme - header.php - add fontawesome

3 replies · Started by Jens on January 5, 2022

Viewing posts 1–4 of 4

Hello,

I try to add a css-file in my child theme header.php.

My first question is, do I have to copy the original header.php into the child theme or does it have to be empty?

The second question is how can I add the CSS file in the header and on which position?

<link rel="stylesheet" href="/css/fontawesome/css/all.css">

Is there a rule in which directory the css data should be located? At the moment I puted it directly in the root of my project.

Update:
I just found under the folder "wp-content\themes\generatepress\assets\fonts\fontawesome-webfont.svg" that the font is already delivered with generatePress. Do I possibly no longer have to integrate it and can I use these files?

Best regards
Jens

Hi there,

Ideally you should use the wp_enqueue_scripts and wp_enqueue_style functions to load a style sheet.
Regarding your update - that is Legacy file when old versions of the theme used Font Awesome.

Personally i would not recommend loading the CSS from the theme or your child theme for FA icons. The files it loads are huge and will tank your sites performance.

If you must use FA Icons then better to use their plugin:

https://wordpress.org/plugins/font-awesome/

It has the option to use SVGs ( instead of WebFonts) which means it just loads the necessary SVG for the icons you choose and not the entire library....

Hi David,

Thanks for your answer. In this case I use the plug-in. That seems to be the easiest way at the moment.

Best regards
Jens

You're welcome

This archived topic is closed to new replies.