Ask News.YC: Is hand-coded html an outdated and silly way to operate a site?
Anyone out there not using some sort of CMS for a site of reasonable complexity?
Anyone out there not using some sort of CMS for a site of reasonable complexity?
<?php
$title = "Whatever";
include("header.php");
include("content.txt"); // or just include the content inline
include("footer.php");
?>
Then header.php is just: <html>
<head>
<title>My Site - <?php echo $title; ?></title>
<!-- other header stuff like css, scripts, etc -->
</head>
<body>
<div id="content">
and footer.php is just: </div>
<!-- other footer stuff like Google Analytics, etc -->
</body>
</html>
If you want to get a little fancier you can set up a URL rewriting (like Apache's mod_rewrite) to internally change yoursite.com/section/subsection to yoursite.com/content.php?a=section&b=subection or something, then you can eliminate all the duplicate templates and just have your content files (make sure you validate the section and subsection names). Or you could plug in a really simple database.I'm no PHP expert, so if anyone has better ways of doing this kind of thing I'd love to hear it.
(actually, I have a question: with this layout it's hard to pass data from included files back up to the templates, like $title above needs to be defined before the header include... is there some trick I'm missing?)
There hasn't been a reason to hand code anything that is at all dynamic or frequently updated for a decade. There's a reason PHP is so popular after all.
That being said, any HTML/CSS that has to do with layout is still best done by hand.
On the spectrum of tools available, what most people are looking for is a hand-coded layout/template with something like wordpress/moveable type generating the content.
For a site of any complexity, I would use a cms, home-brewed or open-sourced though.
Removing the database layer is always a nice option, but if you plan to have any sort of interactivity, straight html might be a pain.