This is how I did it when I first started using PHP includes, and probably what drew me into PHP in the first place.
But now I do it in reverse which I find to be more DRY and maintainable.
So what I have is one page template with a
<head>, <body> and all the common HTML elements in the body, such as a header, menu, sidebar(s),
<main> content holder, footer, etc.
Then the unique content, such as the
<h1> and body content are included.
These may or may not by done via includes. Shorter things like the title may use an echo:-
<title><?= $pageTitle ?></title>
More bulky content may be an actual include:-
<main><?php include $pageContent ?></main>
Or you may even have set up a special function to output things:-
<h1><?php $thisPage->output('pageHeading') ?></h1>
And then the actual template may be an include in the script that defines what the page will be, which has already set up values for the variables within the template.
Now if you decide to completely redesign the page layout, move the sidebar from left to right, put the menu before, not after the header, or in any way drastically change the page structure.
You don’t have the edit all those 30/40 pages, adding, removing, changing the the order of, all the includes, but just edit one template file.
Maybe what I describe is a little deep for a beginner, but food for thought.
While having many includes around the unique page content is the more obvious and seemingly simpler method, in the long term I find the other way simpler to maintain once set up.