posty.site module

class posty.site.Site(site_path='.', config_path=None)[source]

Bases: object

Representation of an entire site with posts and pages. This is the main class that conrols everything.

Parameters:
  • site_path – Path to the directory containing site content (pages, posts, templates)
  • config_path – Path to the config file, defaults to $SITE_PATH/config.yml
config

Returns this site’s config as read from the config file

copyright

Returns a string of the copyright info, based on the configured author and the years of the first and last post

init()[source]

Initialize a new Posty site at the given path

load()[source]

Load the site from files on disk into our internal representation

new_page(name='New Page')[source]

Create a new page in the site directory from the skeleton page

new_post(name='New Post')[source]

Create a new post in the site directory from the skeleton post

page(slug)[source]

Returns a Page object by its slug

Parameters:slug – slug of the page to find
Returns:A page dict
Raises:PostyError – if no page could be found
post(slug)[source]

Returns a Post object by its slug

Parameters:slug – slug of the post to find
Returns:A post dict
Raises:PostyError – if no post could be found
render(output_path='build')[source]

Render the site with the various renderers

  • HTML
  • JSON
  • RSS (if feeds.rss is True in the config)
  • Atom (if feeds.atom is True in the config)