Trollish notes on hosting a web page

(updated )

These are some rantings on what I've learned from having a website.

The simple static site generator

If you know some programming... The idea is: just write a specialized program that generates your website, and just put all of your site content inside of that one program. There is no need for external data files or parsing a markup language. Just run your script (and maybe pipe the output to a file) and it is done!

For example, I have successfully done this with Python, Lua, and Common Lisp. You can just have long string literals for each page and print them out to the page's destination file path.

So then if you are using Python and you have just one webpage, your command to generate your site would look like this:

python site.py > index.html

Since languages commonly have an easy way to do string interpolation or concatenation (not you, C!), you can just put functions or variables inside of or concatenated with your other content strings.

And, if you do this, what have you done in the end? You have basically just used that programming language as static PHP (not dynamically, server-side)!

Mini-pages

If you want to have the appearance of multiple pages on your website, and you're not using a CMS, then you may need to do some extra work to maintain all of those files. But, there is an alternative: put your 'pages' all in the one main page (index.html) as 'mini-pages'. The trick is to use the CSS selector called :target. If you make top-level articles which are all on the same page only show as visible when they are the target link, you get mini-pages.

Since I am nice, here is the template CSS code, which applies to HTML elements with the 'hider' class:

/* Show one article (the currently targeted one) at a time */
.hider { display: none; }
.hider:target { display: block; }