Default header and footer for all pages

1

In the site I'm doing, like most, the header and footer of the page never change, just the contents of the body. With header and footer I mean the whole part that goes beyond <body></body> .

What I'm doing is putting the following codes:

header.php (simplified)

<html>
    <head>
        <title>Título</title>
        <!-- Aqui também incluo scripts de css e js -->
    </head>
    <body>

footer.php (simplified)

    <!-- Incluo mais alguns scripts -->
    </body>
</html>

index.php (simplified)

<?php include 'header.php'; ?>
    <h1>Página</h1>
    <!-- Conteúdo -->
<?php include 'footer.php'; ?>

In the beginning until it was very functional, it did not need to repeat codes. It was a bit confusing, especially in the organization of HTML, but it worked. The problem now is that the project is too big. There are many scripts that should only be loaded on certain pages, not needing to load them all (including header.php or footer.php). I would not like to put in the end of the body of each page as it could not control the loading order (very important when using js). If someone knows some way to get around or solve the problem by library, etc. please help.

PS: I know there is Composer. I have not learned to use it yet, but I believe it can not include header and footer, and if I can, I probably can not choose which scripts to load on each page (my scripts).

    
asked by anonymous 17.05.2018 / 15:56

0 answers