Functions
register
Register SEO helper functions with Jinja2 environment.
register
def register(env: Environment, site: Site) -> None
Register SEO helper functions with Jinja2 environment.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
env |
Environment |
— | |
site |
Site |
— |
meta_description
Generate meta description from text.
Creates SEO-friendly description by:
- Stripping HTML
- Trunc…
meta_description
def meta_description(text: str, length: int = 160) -> str
Generate meta description from text.
Creates SEO-friendly description by:
- Stripping HTML
- Truncating to length
- Ending at sentence boundary if possible
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | Source text |
length |
int |
160 |
Maximum length (default: 160 chars) |
Returns
Meta description textstr
—
meta_keywords
Generate meta keywords from tags.
meta_keywords
def meta_keywords(tags: list[str], max_count: int = 10) -> str
Generate meta keywords from tags.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
tags |
list[str] |
— | List of tags/keywords |
max_count |
int |
10 |
Maximum number of keywords (default: 10) |
Returns
Comma-separated keywordsstr
—
canonical_url
Generate canonical URL for SEO.
canonical_url
def canonical_url(path: str, base_url: str) -> str
Generate canonical URL for SEO.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Page path (relative or absolute) |
base_url |
str |
— | Site base URL |
Returns
Full canonical URLstr
—
og_image
Generate Open Graph image URL.
og_image
def og_image(image_path: str, base_url: str) -> str
Generate Open Graph image URL.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
image_path |
str |
— | Relative path to image |
base_url |
str |
— | Site base URL |
Returns
Full image URL for og:imagestr
—