posty.site module

class posty.site.Site(site_path: str = '.', config_path: str | None = None, config: Config | None = 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

property copyright: str

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

init() None[source]

Initialize a new Posty site at the given path

load() None[source]

Load the site from files on disk into our internal representation

new_page(name: str = 'New Page') None[source]

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

new_post(name: str = 'New Post') None[source]

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

page(slug: str) Page[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: str) Post[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: str = 'build') None[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)