2

I've found myself in a really frustrating situation. I'm currently working on a personal website, and every time I get satisfied with the header and have just updated it in all pages; I usually realize I've made a typo or some other issue. This forces me to fix the issue and, once again, update it in all the files.

So my question is, is there is some smart PHP or Javascript trick for loading in dynamic files and displaying them on the page?


If you didn't find my question clear enough, please read below

Basically, if I have a header like such below

<header>
    <div id="links">
        <a href="#">Link nr. 1</a>
        <a href="#">Link nr. 2</a>
        <a href="#">Link nr. 3</a>
    </div>
</header>

, is it possible to have that header stored in one separate file and load it in dynamically for each page?

Chris
  • 426
  • 2
  • 7
  • 18
  • Read up on how to use server side includes and templates in whatever programming language you have available or use ajax to load one header in all pages – charlietfl Oct 23 '17 at 10:59

1 Answers1

2

Do you use PHP? Then you can make that with PHP include:

<head>

</head>

<body>

<?php include("includes/header.html");?>

</body>
</html>
Patricia
  • 2,885
  • 2
  • 26
  • 32