Considering the folder structure “/public_html/wp-content/themes/TestTheme/static/fontawesome/” as folder location for Font Awesome use following instead
1 use following instead of the one you used for js include
<script defer src="https://wordpress.stackexchange.com/questions/299868/<?php echo get_template_directory_uri(); ?>/static/fontawesome/fontawesome-all.js"></script>
2 use following instead of the one you used for CSS include having fontawesome.min.css file in the CSS folder
<link rel="stylesheet" href="https://wordpress.stackexchange.com/questions/299868/<?php echo get_template_directory_uri(); ?>css/fontawesome.min.css">
The function get_template_directory_uri(), retrieve theme directory URI and can be used to include files located in the active theme.
3 or you can add the following code to your theme functions.php
add_action('wp_enqueue_scripts', 'test_theme_scripts_method');
/*
* Enqueue css and js with the correct path.
*/
function test_theme_scripts_method() {
// Enqueue css
wp_enqueue_style( 'fontawesome_style', get_template_directory_uri() . '/css/fontawesome.min.css', array(), '5.0.9', 'all');
// Enqueue js
wp_enqueue_script( 'fontawesome_script', get_template_directory_uri() . "https://wordpress.stackexchange.com/static/fontawesome/fontawesome-all.js", array('jquery') );
}
The action “wp_enqueue_scripts” is used to enqueue CSS and JS files to site.