Getting started¶
Genja is distributed on PyPI. Instructions for installing and using Genja are given below.
Installation¶
Download and install Python from https://www.python.org or from Anaconda at https://www.anaconda.com. After installing Python, create and activate a virtual environment as shown below:
python -m venv .venv
source .venv/bin/activate
Install the Genja package in your Python environment using pip:
pip install genja
Check the installed version from the command line:
genja --version
Usage¶
Before running genja, create a project structure as shown below. Or create a new example project by using the genja new
command. Markdown files go into the pages and posts directories. The pages directory is for standalone content that is not dated such as an about page or contact page. The posts directory is for dated content such as blog posts or articles. The templates directory contains Jinja templates that are used to render the HTML pages and posts. The mysite directory contains the built website which can be hosted with GitHub Pages or some other web hosting platform. Lastly, the config.toml defines the URLs and directories for the project.
myproject/
├── mysite/
│ ├── img/
│ └── styles.css
├── pages/
│ ├── about.md
│ └── contact.md
├── posts/
│ ├── apple.md
│ └── orange.md
├── templates/
│ ├── index.html
│ ├── page.html
│ └── post.html
└── config.toml
The items in the config.toml are shown below. The base_url
is the URL for the homepage of the website. The posts_output
defines the output directory for the generated HTML posts. All of the HTML files generated from Genja are located in the site_output
directory. Static content such as images and CSS files should go in this directory. The title of the website is defined by the title
key.
base_url = "https://example.com"
posts_output = "blog"
site_output = "mysite"
title = "My Website"
Use the serve
command to build the website and start a local server. This will automatically open the default web browser to view the website. The website will automatically reload when changes are saved to the Markdown files.
genja serve
Use the build
command to build the website without running a local server.
genja build
Use the clean
command to remove all the generated HTML files and the JSON feed file.
genja clean