Serve static sites directly from your repositories.
Project description
Welcome to PageKit
PageKit is a versatile, high-performance web server designed to serve content from various sources, making it easy to publish websites directly from git repositories or a local directory. It is built with Python and FastAPI, offering a lightweight and powerful solution for personal and organizational web hosting.
Core Concepts
At its core, PageKit dynamically serves web content based on the incoming request. It can operate in different modes, allowing it to be a simple static site server for local development, a GitHub/Gitea Pages-like server for git repositories, or a full-fledged multi-tenant SaaS platform.
Key features include:
- Markdown-to-HTML Conversion: Automatically renders Markdown files as HTML pages.
- Jinja2 Templating: Uses the powerful Jinja2 templating engine to build dynamic and reusable layouts.
- Frontmatter Support: Extracts metadata (like
title,author,layout) from Markdown files to use within templates. - Flexible Configuration: Easily configured through environment variables.
Operating Modes
PageKit can be run in one of three modes, configured via the APP_MODE environment variable.
1. Repo Mode (APP_MODE="repo")
This is the default and most powerful mode. It serves content directly from a git repository (like Gitea). The server interprets the request's hostname to determine which organization and repository to pull content from.
Example: A request to my-org.pages.yourdomain.com will look for a repository (e.g., pagekit) within the my-org organization on your configured git instance.
2. Local Mode (APP_MODE="local")
Ideal for development, testing, or simple single-site hosting. In this mode, PageKit serves files directly from a specified local directory on the filesystem. It provides the same Markdown rendering and templating capabilities as the repo mode.
3. Platform Mode (APP_MODE="platform")
This mode is designed for multi-tenant, SaaS-like deployments. It will use a database to manage different users/organizations, allowing each to have their own repository configurations and access tokens.
Note: This mode is currently under development.
Configuration
PageKit is configured using an .env file in the project root.
| Variable | Description | Required For | Default Value |
|---|---|---|---|
APP_MODE |
The operating mode. Can be repo, local, or platform. |
All | "repo" |
REPO_URL |
The full URL to your git instance (e.g., https://gitea.example.com). |
repo mode |
(None) |
REPO_TOKEN |
A git API token with read-access to the repositories. | repo mode |
(None) |
DEFAULT_REPO |
The default repository name to look for within an organization if not specified as a subdomain. | repo mode |
"pagekit" |
LOCAL_CONTENT_DIR |
The absolute or relative path to the directory containing your content and templates for local serving. | local mode |
(None) |
DATABASE_URL |
The connection string for the database. | platform mode |
(None) |
DEBUG |
Set to true to enable debug logging and verbose error messages. |
All | false |
Getting Started
Running in Local Mode
-
Set the Environment Variables: In your
.envfile, configure the following:APP_MODE="local" LOCAL_CONTENT_DIR="docs" # Or your own content directory DEBUG=true -
Create Content: Your
LOCAL_CONTENT_DIRshould contain your website's files (index.md,styles.css, etc.) and atemplatesdirectory for your Jinja2 layouts. See theexamples/docsdirectory for an example structure. -
Run the Server:
uvicorn pagekit.main:appVisit
http://localhost:8000in your browser.
Running in Repo Mode
-
Set the Environment Variables: In your
.envfile, configure the following:APP_MODE="repo" REPO_URL="https://your-gitea-instance.com" REPO_TOKEN="your-secret-gitea-token" DEFAULT_REPO="my-website" DEBUG=true -
Run the Server:
uvicorn pagekit.main:app -
Access Your Site: To access the content, you need to simulate a request with the correct hostname. You can do this by editing your local
/etc/hostsfile to point a custom domain to127.0.0.1:127.0.0.1 my-org.localhostThen, visit
http://my-org.localhost:8000in your browser. PageKit will fetch content from themy-websiterepository in themy-orgorganization on your Gitea instance.
Content & Templating
Markdown and Frontmatter
Create content pages using Markdown. At the top of your .md file, you can include a YAML frontmatter block to define metadata.
Example: about.md
---
title: About Our Company
layout: layouts/page.html
author: John Doe
---
# Welcome to our page!
This is where you can write your content in Markdown...
title: The title of the page, often used in the<title>tag or a heading.layout: Specifies which template file to use from thetemplatesdirectory. If omitted, it defaults tolayouts/page.html.- Any other variables (e.g.,
author) are passed directly to the template.
Jinja2 Templates
Templates are located in the templates subdirectory of your content source (LOCAL_CONTENT_DIR or the git repo). You can use the full power of Jinja2 to create reusable layouts.
Example: templates/layouts/base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
</head>
<body>
<header>
<h1>{{ title }}</h1>
</header>
<main>
{{ content | safe }}
</main>
</body>
</html>
{{ title }}: Renders thetitlefrom the frontmatter.{{ content }}: This is where the rendered HTML from your Markdown file will be injected. Use the| safefilter to ensure HTML is not escaped.
Deployment
For production, it is recommended to run PageKit as a Docker container, ideally within a Kubernetes cluster. The project includes a Dockerfile and sample Kubernetes manifests in the /k8s directory to get you started. Please refer to the README.md for more detailed deployment instructions.
Project details
Release history Release notifications | RSS feed
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 pagekit-0.2.1.tar.gz.
File metadata
- Download URL: pagekit-0.2.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6784911b159e777ead91454ccedb8560a8349a19d5cc08946d5c0e2b235c6ceb
|
|
| MD5 |
ce2f2f88363771345c69aa34660a942a
|
|
| BLAKE2b-256 |
e27db983f6ee02496e93db99d5b39c92e693f39ec68bee3fa3908e751a9e3e6b
|
File details
Details for the file pagekit-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pagekit-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaa57ab2179f9d76fa2f33833235e8198fe2689bafbc3aef82b00ec29cde5450
|
|
| MD5 |
7216a66fb100d79ffdb069ee1959af69
|
|
| BLAKE2b-256 |
64338f21aaec769d08bed3e1969f06084f3663b84f73f496075cc044ca0a33a1
|