The header.php file

First, we will create a header file. You can do so with the following steps:

  1. Cut out the entire top of your index.php file. This means cutting the doctype declaration, the <head> tag, any miscellaneous opening tags, and the <header> tag. In my case, I'm cutting out all the way from this initial line:
      <!DOCTYPE html>
  1. I'm cutting through to, and including, these lines:
      </header><! -  #masthead  - >
      <div id="content" class="site-content">
  1. Paste all these lines into a new file named header.php, which you created within your theme directory.
  2. Now, at the very top of the index.php file (that is, where you just cut the header text from), type in the following line of WordPress PHP code:
      <?php get_header(); ?>
  1. This is a WordPress function that includes the header.php file you just created.

If you save everything and reload your website now, nothing should change. The important part here is to make sure that the call to the preceding PHP function sits right at the very top of your index.php file.