| Home | Archive | About |
This site is a slowly evolving proof-of-concept to show how txt2tags can be used as a general purpose blogging engine.
Mon 15 Oct 2007 09:30:17 PM BST
txt2tags is a small (485k download) command-line application for Linux and similar Operating Systems. It takes any text file with a bare minimum of markup and converts it into a beautifully formatted document in any of several formats, including html, pdf, TeX and Pagemaker - all from the same source. This is perfect if you want to provide a document in several formats with the minimum of effort, or want to create pdfs without needing a resource-heavy word processor.
For the purposes of blogging though, the main goal is to take a text file, use txt2tags to convert it to html and upload it to the server.
There are several advantages to using txt2tags as your blogging engine of choice:
Of course, there are a few downsides, most notably the lack of rss, searching and tags. These can easily added however; I'll save that particular trick for a future blogpost though. Let's keep things simple for now :)
So, can it be done? Obviously, as you are reading this, it can. This entire site was created using txt2tags and any old text editor. Even the stylesheet is the example modern.css provided with the txt2tags package, and can easily be customized to taste.
First, you need a template for your blog. Here's the one for this site:
txt2blog Robin V. Stacey :: greywulf (at) gmail.com (c) Creative Commons Attribution ShareAlike 2007 | [Home index.html] | [Archive archive.html] | [About about.html] = First Post! = //Put the date here// **Hello world**! Replace this text, and start //blogging//. [Add Comment mailto:greywulf@gmail.com] (Opens mail window. Comments are moderated.)
Just download and install txt2tags copy and paste the text above into a new file called yoursitename.t2t (or whatever), and you're all set.
Here's how it works. The first line is the name of your site. The second is your name and contact information and the third (usually reserved in txt2tags for the publication date) is the copyright notice. Adjust to suit. The fourth line is optional. It puts a row of links to other pages on the site. Remove this if you want one (potentially very long) blog, or set to your preference.
After that, everything else is blog.
A blogpost has a title surrounded by single = marks. Underneath, add the date. Text is just plain text with blank lines to denote paragraphs. Use square brackets to create links (for example, [Home txt2blog.html] gives Home), and surround the text with double asterisks (**like this**) and double slashes (//like this//) for bold and italic. To post images, surround the filename with square brackets like this: [hotrod1.jpg].
Put the image directly before a paragraph on the same line and it will align with it. If you need more than this, check the txt2tags documentation.
If you want comments (and who doesn't?), copy and paste the following line underneath each post, replacing the email address:
[Add Comment mailto:greywulf@gmail.com] (Opens mail window. Comments are moderated.)
When you receive a comment, just add it to the text in the correct location.
Each time you want to make a new post, just start a new entry at the top of the .t2t file. When you reach around 10 posts, consider moving the bottom items into an archive.t2t file to keep the main page a sensible size.
Finally, copy the modern.css file from /usr/share/doc/txt2tags/examples/css into the same location as your blog. This controls the page layout, so adjust as required.
Use txt2tags to make the .html file and copy it to the server. The following script, called makeblog, handles all this by generating the html page with modern.css specified, then using scp to upload to files. Remember to replace my details with yours!
#!/bin/bash txt2tags -t html -o index.html --css-sugar --style=modern.css txt2blog.t2t # If you're using an archive, uncomment the next line to have it updated as well. # txt2tags -t html -o archive.html --css-sugar --style=modern.css archive.t2t # # .... add extra pages as required. scp * greywulf@greywulf.net:~/greywulf.net/txt2blog/
There you have it. A blog, using txt2tags. Clever, eh?
If you use this, please send me a comment!
Add Comment (Opens mail window. Comments are moderated.)