A minimal static site generator.
Project description
kilvin
Kilvin is a simple static site generator. It takes markdown text and turns it into a static webpage using layouts. Changes can be made to the page's content, URLs, and the way the site looks.
- Minimal templating language
- Minimal config with support for custom variables
- Automatic table of contents generation
Getting Started
Prerequisites
Kilvin requires the following:
- Python version 3.9 or higher
- pip : package installer
Instructions
- Install all prerequisites.
- Install the
kilvin.
$ pip install kilvin
Create a site
- Create a new kilvin site at
./my_project
$ kilvin init my_project
- Change into your new directory.
$ cd my_project
- Build the site.
$ kilvin build
- Make it available on local server.
$ kilvin server
Command Line
Kilvin has several commands:
Usage: kilvin [OPTIONS] COMMAND [ARGS]...
Kilvin is a simple static site generator. It takes markdown text and turns
it into a static webpage using layouts.
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
build Build the current project
init Create directory structure for the project
new Create a new markdow post in ./content dir
server Serve the current project
Here are some of the most common command:
-
kilvin init PATH:- Create a new kilvin site with requisite directory structure.
-
kilvin new PATH:-
Help create new markdown pages for the project.
-
All the new pages are stored in content directory.
-
Example:
For
content/about.md$ kilvin new about.md
For
content/blog/today.md$ kilvin new blog/today.md
-
-
kilvin build:- Build the site from
./contentfiles using template in./layoutand save them./publicdirectory. - All the non-markdown files in
./contentare copied directly without any changes. ./staticis also directly copied to./public.
- Build the site from
-
kilvin server:- Serves the site locally.
Config
Edit config.toml for changing the configuration for the project.
Default Configuration
Basic configuration required for building the site.
title = 'My Blog'
url = "https://myblog.xyb"
description = 'My corner of the internet.'
[author]
name = "Kilvin"
email = "kilvin@myblog.xyb"
Custom Configuration
Custom variables can also be defined in config.toml.
var1 = 123
[name1]
var2 = "abcxyz"
var3 = 123
All the variables in config.toml can be accessed in HTML templates with site variable.
Example:
{{ site.title }}{{ site.author.name }}{{ site.name1.var2 }}
Pages & Layouts
kilvin organize the rendered site in the same structure that is used to organize the source conent.
└── content
└── about.md
├── posts
| └── _index.md
| ├── firstpost.md
| └── secondpost.md
└── quote
└── _index.md
├── first.md
└── second.md
└── public
└── about
| └── index.html
├── posts
| └── index.html
| ├── firstpost
| | └── index.html
| └── secondpost
| | └── index.html
└── quote
└── index.html
├── first
└── index.html
└── second
└── index.html
Pages
- All markdown files are referred as a Pages.
Creating a Page
-
To create a page, add a markdown file to
./contentdirectory. -
Pages can also be organized in sub directories, and all sub directories should have a
_index.mdpage. -
All pages must have a front matter, enclosed in
---which is used to specify the template or other meta data, along with custom data.Example:
--- template: single.html title: Why does it have to end? subtile: A survivor dies. date: 2022-28-09 --- [TOC] markdown here
template,tilte,subtitleanddateare mandatory.- If
templatefield is empty, then default templates are used.
-
All the variables can be accessed using
metavariable in template.-
Example
{{ meta.title }}{{ meta.subtitle }}{{ meta.date }}
-
Index Page
- All the directories should have
_index.mdpage. - Index Page is special as it has access to variable
pages.
Layout
- kilvin uses Jinja2 for templating.
./layoutcontains the templates for the Pages../layoutshould havelist.htmlandsingle.htmlas the default templates.
Variables
All the templates have access to a bunch of variables.
site: date inconfig.tomlmeta: data from front matter of the pagebody: rendered markdown from the pagepages: (only available to index template) list of all the page in directory
Template Usage
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ site.title }}</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/blog/">Blog</a>
</nav>
<h1>{{ meta.title }}</h1>
<section>
{{ body }}
</section>
</body>
</html>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kilvin-0.4.tar.gz.
File metadata
- Download URL: kilvin-0.4.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54a172f978c0a3cde6e105f9ec653b5c0e427c7404a390aed453db513694bd6d
|
|
| MD5 |
76db2f1fd07afa0ee6458224bca3cee8
|
|
| BLAKE2b-256 |
f0f817541f0f78cc7e81610c1d39bf43c29eb41931a405f6a4cb6cefc6603e75
|
File details
Details for the file kilvin-0.4-py3-none-any.whl.
File metadata
- Download URL: kilvin-0.4-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d4e5655c88a76ccf06042d76245cf795a2c53d02b26ae21537c741cfc3a5f94
|
|
| MD5 |
5483f1b245a7f4c58c364d58ed48034e
|
|
| BLAKE2b-256 |
c686f7b9da5089b6e868c27baadf548e326d9a4c01279f485c3adfe662b9238c
|