I would like to add a menu or footer like in Wordpress or any other CMS.
That really dont work with PHP includes because if a website file is in subdirectory there is a problem with the path. As you know a normal static menu looks like
<nav>
<ul>
<li><a href="about.php">About</a></li>
</ul>
</nav>
but CMS menu looks like
<nav>
<ul>
<li><a href="/about/">About</a></li>
</ul>
</nav>
And that on all pages so no problems with the path if you try it with static/dynamic pages you have to add the path or the url and that looks really ugly or not
<?php
define('WEB_ROOT', '../'); // relative path to /
?>
...
<nav>
<ul>
<li><a href="../../solution/">Solution</a></li>
or
<li><a href="https://example.com/solution/">Solution</a></li>
or
<li><a href="<?php echo WEB_ROOT; ?>solution">Solution</a></li>
</ul>
</nav>
I think thats a bad idea and really ugly. so how to solve that kind of problem maybe with adding a web root in php like above but looks not really good so do you have any other ideas? And that Solution should also work for CSS and JS not only for static contents, so all styles are same and menus looks just like the other pages even if it is in the subdirectories