p sure you're looking for a web component. You'll create a new component that can be used like
<my-header></my-header>
Then import the file with the definition of the custom web component on both pages et voilà! You've shared your header between pages.
I will admit I'm a bit biased because I'm the author of a web component framework: https://tybalt.org . But! I still think that's what you're looking for.