Comment by creesch
3 hours ago
While purists will disagree, a little bit of javascript is fine. Having said that, you are talking about a personal website. Most companies will have a backend of some sort anyway.
Also, here is a little secret. If you want something that is future proof, try something that has been around for decades and still runs large parts of the internet. People will scoff at this, but PHP is actually really neat for personal websites and has been for decades.
A while ago I also found myself looking at static site generators, workflows from github to my host, etc. Eventually I realized I don't update things nearly enough, don't blog, etc.
For similar reasons as you I didn't want to go completely static as that is just too much hassle when doing multiple pages. So I decided to utilize that good old lamp stack to basically do something like this.
<?php
$pages = json_decode(file_get_contents('pages.json'), true);
$page = $_GET['page'] ?? 'home';
if (!isset($pages[$page])) {
$page = 'home';
}
$pageData = $pages[$page];
$contentFile = basename($pageData['file']);
$contentFilePath = "content/{$contentFile}";
?>
<html>
<head>
<title><?= htmlspecialchars($pageData['title']) ?></title>
</head>
<body>
<main>
<?php include $contentFilePath; ?>
</main>
</body>
</html>
Slightly more, but the base principle is the same. Just 10 lines of php code, and now I can just add pages by uploading their contents and adding them to the json file for whitelisting. For your use case it would be trivial to add a menu based on the json file and I'd be confident that it will still work in 10 years with minimal adjustments.
As a bonus I also rediscovered PHP in itself works really well as a templating language (as you can see) so no need for extra stuff like handlebars. As an extra extra bonus, I can just go to any shared webhosting party and get it running with no issue at all.
I am not saying you'd need to go down this road. But I just want to illustrate how stupidly simple a website can be with "old" basic technologies even if you want some form of backend.
No comments yet
Contribute on Hacker News ↗