Skip to content
matt-west edited this page Mar 28, 2012 · 1 revision

Adding New Posts

To add a new post you need to create a new file in the /posts/ directory and add your post content to it. (Note: You currently have to add the header and footer matter to this file too, this will be changing in the future.) Once you have got your post sorted you need to add a new entry to the posts.json file in /data/. The file is ordered with the latest posts at the top. Be sure to add information for all of the following fields:

  • Title - Post Title
  • Slug - This will be used as the URL slug, it should be the same as the html file that you created for the post without the .html extension
  • Date - The human readable published date
  • MachineDate - A machine readable date (i.e. YYYY-MM-DD). This will be used in the <time> tag in the post footer and also in the RSS feed
  • Keywords - Meta Keywords
  • Description - Meta Description. This is also used as the post snippet in the RSS feed.
  • Tags - An array of strings

Adding New Pages

Follow the instructions for adding a new post but use the data/pages.json JSON dict and pages folder. The Page struct has the following properties:

  • Slug - This will be used as the URL slug, it should be the same as the html file that you created for the page without the .html extension
  • Title - Page Title
  • Keywords - Meta Keywords
  • Description - Meta Description

Request Handlers

  • archiveHandler - Responds to requests to /archive
  • assetHandler - Responds to requests for css, js, etc. /assets/
  • indexHandler - Does not respond directly to a request, called by the postHandler if no post slug is present in the URL
  • pageHandler - Responds to requests to /page/
  • postHandler - Responds to requests to /, will grab the post slug and calls the indexHandler if no slug is present
  • rssHandler - Responds to requests to /rss, returns an XML RSS Feed of all posts
  • tagHandler - Responds to requests to /tag/

Static Assets

Static assets such as favicons and humans.txt files are served by the postHandler. Before attempting to return a post the handler will iterate through the staticAssets slice and return the relevant file if the file requested is present.


In-Memory Templates

Page, Post, Layout and Error templates are all parsed when the program is started and held in memory. The advantage of this is that the you don't have to read files every time there is a request. The disadvantage is that you must restart the program if you add new pages/posts or make changes to any of the templates. (I'm working on this problem)

The pages and posts JSON dictionaries are also read on start and held in memory.

Clone this wiki locally