Template files and hierarchy

Template files are also a part of your theme and play an important role in how the website is displayed to the site visitors. It mainly deals with the website layout and its components. Some examples of the template files are header.php, comments.php, and index.php.

By the way, the template files in WordPress are reusable. This means that you can use query strings to call a template or a set of templates dynamically. These query strings look for template files with specific names in the current theme’s directory and use the first matching template file as specified by the hierarchy.

For a more detailed understanding of the WordPress template hierarchy, you may have a look at the below resources.

Alicia St Rose: Wrangle the WordPress Template Hierarchy Like a Boss from WordPress.tv | (CC BY-SA 4.0)