Search code examples
embedding

Automatically embed HTML files at page load


I'm looking to embed html files at page load (of home page, index). All html files are in the same directory as index. The html files are random file names, and are always being added. They need to be automatically loaded at page load, for that reason.

I'm not great with HTML, but it seems you can't do it with just HTML. I've been searching for some kind of method, but haven't found anything. What do I use? Javascript? PHP?


Solution

  • Using HTML:

    Include an import on your page by declaring a <link rel="import">

     <head>
         .....
        <link rel="import" href="/path/to/imports/stuff.html">
    
     </head>
    

    Using PHP

      <?php include("/path/to/imports/stuff.html"); ?>
    

    Or

     <?php require_once("/path/to/imports/stuff.html"); ?>