Introduction to Petk
Welcome to Petk, a powerful template toolkit designed to streamline your template processing workflows. This guide will help you get started with Petk and understand its core concepts.
What is Petk?​
Petk is a comprehensive template engine and processing toolkit that enables developers to:
- Process Markdown files with dynamic content inclusion
- Convert between Markdown and YAML formats
- Apply template transformations with powerful directive blocks
- Manage complex template hierarchies and dependencies
Getting Started​
Installation​
Install Petk using your preferred package manager:
# Using npm
npm install -g petk
# Using pnpm
pnpm install -g petk
# Using yarn
yarn global add petk
Your First Template​
- Create a new Markdown file called
example.md
:
# My First Template
This is a basic template that will be processed by Petk.
```{petk:include}
path: header.md
```
Welcome to the content section!
```{petk:include}
path: footer.md
```
- Create the included files:
header.md:
## Header Section
This content is included from another file.
footer.md:
---
*Footer content goes here*
- Process the template:
petk process example.md
Core Concepts​
Template Directives​
Petk uses special directive blocks to control template processing:
{petk:include}
- Include content from other files{petk:config}
- Set processing configuration{petk:transform}
- Apply transformations to content
File Processing​
Petk can process individual files or entire directories:
# Process a single file
petk process template.md
# Process all files in a directory
petk process ./templates/
# Convert formats
petk convert input.md output.yaml
Next Steps​
- Learn about CLI commands for detailed usage
- Explore common troubleshooting solutions
- Understand the architectural concepts behind Petk
Quick Reference​
Command | Description |
---|---|
petk process <file> | Process a template file |
petk convert <input> <output> | Convert between formats |
petk --help | Show available commands |
petk --version | Display version information |
Ready to dive deeper? Check out our comprehensive CLI reference for all available commands and options.