A lot of it is just familiarity with when and how to use certain techniques, and invariably you end up coming across similar situations time and time again and become faster at quickly knowing what to do...
For example the other day I was updating and tidying up some webpages written by someone else, which consisted of several nested pages each containing a big grid of sort of "link-boxes" - each had a coloured title bar, a picture and a line of descriptive text. The html was quite a mess and I began to wonder how the original author had the patience to type it all out or maintain it. My thought process from there was:
- The process for defining each box in this table is very similar, with only a few key things changing in each box (the text, the image and the link destination)
- It would be nice if adding or changing the content in the boxes in the future wasn't as laborious as it would be now
- But the boxes probably don't change frequently enough to need updating every time the page loads
And I instantly reached for a few bits of code I'd used before to cobble together what I feel is a solution fairly in keeping with the UNIX tradition:
A raw txt file with delimited entries of this form:
title text : image location : link destination : description text
which supports # comment lines and understands an escaped "\:" in case it appears in any of the arguments, created for each required page's table. This is complimented with a short bash script that parses the file and writes out the html.
Stick those files plus the script into a subdirectory where the pages are with a simple Makefile that can regenerate the html from all of the pages where the txt file has been updated, set the pages to include the generated html files and there you go - it's super easy to add new entries or modiy existing ones, and also very easy to edit the script to make changes to how the produced html looks across all the pages at once (though some of this is done with CSS already)
Disclaimer: Of course this isn't by any means the most super-amazing untouchable way to do things - as always there are many different approaches and I would be very surprised if this is the most efficient/elegant (I expect there is a neater way to do this with some javascript, but I'm more familiar with shell script).
Hacking something together like that is what programming in Linux shell is all about in my opinion...