Not sure why you're wanting to use variables. What I do is use php and have a header.php file that has all the header html and footer.php that has all the footer html. Then, on the regular page I include them like so:
<html>
<body>
<?php include 'header.php'; ?>
(body html)
<?php include 'footer.php'; ?>
</body>
</html>
And if you want to use php variables in the main html, you can put the body html in an echo:
<html>
<body>
<?php
include 'header.php';
echo "(body html {$phpvariable} more body html)";
include 'footer.php';
?>
</body>
</html>