I wonder how other webmasters organize their site structure and keep the navigation menu / links / sidebar the same on all of their static pages. I currently have my homepage hosted on neocities and the nonexistent php support is driving me nuts sometimes.
How are you keeping your navbar or sidebar up to date on all of your pages?And what are the pros and cons of each option in your opinion?
There are several optionsLets say you want to include your nav menu into all of your pages without the need to edit every static site once one of your links gets updated, removed or a new one gets added.
None of those that are working on neocities (marked with ✔) is appealing to meJS client side includes ✔
JavaScript includes work on the client side and include the content of file from the server by injecting the content into the html of the parent document within the browser. This is an easy approach when hosting on neocities but it doesn't work when a visitor has turned off javascript. With the usage of <noscript>a fallback navmenu in plain html can be placed here</noscript> to show a navbar for those users.
Usage:
index.html
<script src="nav.js"></script>
nav.js (this is for newer browsers, fallback code for older browsers can be found
heredocument.write(`
<a href="/">Home</a> - <a href="/links.html">Links</a> - <a href="/guestbook.html">Guestbook</a>
`);
HTML frameset ✔ but deprecated in HTML5
After my first websites back in the day I got told that using frames is SO WRONG after which I adapted to using php include. I never looked back to using a frameset.
<frameset cols="30%, 40%, 30%">
<frame name="top" src="nav.html" />
<frame name="main" src="home.html" />
<frame name="bottom" src="footer.html" />
<noframes>
<body>Your browser does not support frames. (You can show the content without frames here)</body>
</noframes>
iframes ✔
Usage:
SSI - Server side includesUsage:
<!--#include file="nav.html" -->
PHP includesUsage:
index.php (or index.html when parsing is on)
<?php include 'nav.php';?>
or
<?php require 'nav.php';?>
nav.php
<?php
echo '<a href="/">Home</a> - <a href="/links.html">Links</a> - <a href="/guestbook.html">Guestbook</a>';
?>
There are other ways to achieve this as well but they doesn't
listed here seem to work on neocities webspace (please correct me if I'm wrong)
What is your opinion on this subject?