Classes
PageProxy
Lazy-loaded page placeholder.
Holds page metadata from cache and defers loading full content until…
PageProxy
Lazy-loaded page placeholder.
Holds page metadata from cache and defers loading full content until accessed. Transparent to callers - implements Page-like interface.
LIFECYCLE IN INCREMENTAL BUILDS:
Discovery (content_discovery.py):
- Created from cached metadata for unchanged pages
- Has: title, date, tags, slug, _section, _site, output_path
- Does NOT have: content, rendered_html (lazy-loaded on demand)
Filtering (incremental.py):
- PageProxy objects pass through find_work_early() unchanged
- Only modified pages become full Page objects for rendering
Rendering (render.py):
- Modified pages rendered as full Page objects
- PageProxy objects skipped (already have cached output)
Update (build/rendering.py Phase 15):
- Freshly rendered Page objects REPLACE their PageProxy counterparts
- site.pages becomes: mix of fresh Page (rebuilt) + PageProxy (cached)
Postprocessing (postprocess.py):
- Iterates over site.pages (now updated with fresh Pages)
- ⚠️ CRITICAL: PageProxy must implement ALL properties/methods used:
- output_path (for finding where to write .txt/.json)
- url, permalink (for generating index.json)
- title, date, tags (for content in output files)
TRANSPARENCY CONTRACT:
PageProxy must be transparent to:
- Templates: Implements .url, .permalink, .title, etc.
- Postprocessing: Implements .output_path, metadata access
- Navigation: Implements .prev, .next (via lazy load)
⚠️ When adding new Page properties used by templates/postprocessing, MUST also add to PageProxy or handle in _ensure_loaded().
Usage:
# Create from cached metadata
page = PageProxy(
source_path=Path("content/post.md"),
metadata=cached_metadata,
loader=load_page_from_disk, # Callable that loads full page
)
# Access metadata (instant, from cache)
print(page.title) # "My Post"
print(page.tags) # ["python", "web"]
# Access full content (triggers lazy load)
print(page.content) # Loads from disk and parses
# After first access, it's fully loaded
assert page._lazy_loaded # True
Attributes
| Name | Type | Description |
|---|---|---|
_site |
Site | None |
Methods 59
title
property
Get page title from cached metadata.
title
property def title(self) -> str
Get page title from cached metadata.
Returns
str
date
property
Get page date from cached metadata (parsed from ISO string).
date
property def date(self) -> datetime | None
Get page date from cached metadata (parsed from ISO string).
Returns
datetime | None
tags
property
Get page tags from cached metadata.
tags
property def tags(self) -> list[str]
Get page tags from cached metadata.
Returns
list[str]
slug
property
Get URL slug from cached metadata.
slug
property def slug(self) -> str | None
Get URL slug from cached metadata.
Returns
str | None
weight
property
Get sort weight from cached metadata.
weight
property def weight(self) -> int | None
Get sort weight from cached metadata.
Returns
int | None
lang
property
Get language code from cached metadata.
lang
property def lang(self) -> str | None
Get language code from cached metadata.
Returns
str | None
type
property
Get page type from cached metadata (cascaded).
type
property def type(self) -> str | None
Get page type from cached metadata (cascaded).
Returns
str | None
variant
property
Get visual variant from cached metadata (Mode).
Falls back to legacy layout/he…
variant
property def variant(self) -> str | None
Get visual variant from cached metadata (Mode).
Falls back to legacy layout/hero_style fields in props if not set.
Returns
str | None
props
property
Get custom props from cached metadata.
This provides access to the 'props' dic…
props
property def props(self) -> dict[str, Any]
Get custom props from cached metadata.
This provides access to the 'props' dictionary (formerly metadata) without loading the full page.
Returns
dict[str, Any]
section
property
Get section path from cached metadata.
section
property def section(self) -> str | None
Get section path from cached metadata.
Returns
str | None
relative_path
property
Get relative path string (alias for source_path as string).
relative_path
property def relative_path(self) -> str
Get relative path string (alias for source_path as string).
Returns
str
aliases
property
Get redirect aliases from cached metadata.
aliases
property def aliases(self) -> list[str]
Get redirect aliases from cached metadata.
Returns
list[str]
content
property
Get page content (lazy-loaded from disk).
content
property def content(self) -> str
Get page content (lazy-loaded from disk).
Returns
str
metadata
property
Get metadata dict from cache (no lazy load).
Returns cached metadata including…
metadata
property def metadata(self) -> dict[str, Any]
Get metadata dict from cache (no lazy load).
Returns cached metadata including cascaded fields like 'type'. This allows templates to check page.metadata.get("type") without triggering a full page load.
Returns
dict[str, Any]
rendered_html
property
Get rendered HTML (lazy-loaded).
rendered_html
property def rendered_html(self) -> str
Get rendered HTML (lazy-loaded).
Returns
str
links
property
Get extracted links (lazy-loaded).
links
property def links(self) -> list[str]
Get extracted links (lazy-loaded).
Returns
list[str]
version
property
Get version (lazy-loaded).
version
property def version(self) -> str | None
Get version (lazy-loaded).
Returns
str | None
toc
property
Get table of contents (lazy-loaded).
toc
property def toc(self) -> str | None
Get table of contents (lazy-loaded).
Returns
str | None
toc_items
property
Get TOC items (lazy-loaded).
toc_items
property def toc_items(self) -> list[dict[str, Any]]
Get TOC items (lazy-loaded).
Returns
list[dict[str, Any]]
output_path
property
Get output path (lazy-loaded).
output_path
property def output_path(self) -> Path | None
Get output path (lazy-loaded).
Returns
Path | None
parsed_ast
property
Get parsed AST (lazy-loaded).
parsed_ast
property def parsed_ast(self) -> Any
Get parsed AST (lazy-loaded).
Returns
Any
related_posts
property
Get related posts (lazy-loaded).
related_posts
property def related_posts(self) -> list[Page]
Get related posts (lazy-loaded).
Returns
list[Page]
translation_key
property
Get translation key.
translation_key
property def translation_key(self) -> str | None
Get translation key.
Returns
str | None
url
property
Get the URL path for the page (lazy-loaded, cached after first access).
url
property def url(self) -> str
Get the URL path for the page (lazy-loaded, cached after first access).
Returns
str
relative_url
property
Get the relative URL (without baseurl) for the page (lazy-loaded, cached after …
relative_url
property def relative_url(self) -> str
Get the relative URL (without baseurl) for the page (lazy-loaded, cached after first access).
Returns
str
permalink
property
Get the permalink (URL with baseurl) for the page (lazy-loaded, cached after fi…
permalink
property def permalink(self) -> str
Get the permalink (URL with baseurl) for the page (lazy-loaded, cached after first access).
Returns
str
meta_description
property
Get meta description (lazy-loaded from full page).
meta_description
property def meta_description(self) -> str
Get meta description (lazy-loaded from full page).
Returns
str
reading_time
property
Get reading time estimate (lazy-loaded from full page).
reading_time
property def reading_time(self) -> str
Get reading time estimate (lazy-loaded from full page).
Returns
str
excerpt
property
Get content excerpt (lazy-loaded from full page).
excerpt
property def excerpt(self) -> str
Get content excerpt (lazy-loaded from full page).
Returns
str
keywords
property
Get keywords (lazy-loaded from full page).
keywords
property def keywords(self) -> list[str]
Get keywords (lazy-loaded from full page).
Returns
list[str]
parent
property
Get the parent section of this page.
Returns parent section without forcing fu…
parent
property def parent(self) -> Any
Get the parent section of this page.
Returns parent section without forcing full page load (uses _section).
Returns
Any
ancestors
property
Get all ancestor sections of this page.
Returns list of ancestor sections from…
ancestors
property def ancestors(self) -> list[Any]
Get all ancestor sections of this page.
Returns list of ancestor sections from immediate parent to root without forcing full page load (uses _section property).
Returns
list[Any]
is_home
property
Check if this page is the home page.
is_home
property def is_home(self) -> bool
Check if this page is the home page.
Returns
bool
is_section
property
Check if this page is a section page.
is_section
property def is_section(self) -> bool
Check if this page is a section page.
Returns
bool
is_page
property
Check if this is a regular page (not a section).
is_page
property def is_page(self) -> bool
Check if this is a regular page (not a section).
Returns
bool
kind
property
Get the kind of page: 'home', 'section', or 'page'.
kind
property def kind(self) -> str
Get the kind of page: 'home', 'section', or 'page'.
Returns
str
description
property
Get page description.
Favors core.description (fast, cached) but falls back to…
description
property def description(self) -> str
Get page description.
Favors core.description (fast, cached) but falls back to full page load if not available, for backward compatibility.
Returns
str
draft
property
Check if page is marked as draft.
draft
property def draft(self) -> bool
Check if page is marked as draft.
Returns
bool
hidden
property
Check if page is hidden (unlisted).
hidden
property def hidden(self) -> bool
Check if page is hidden (unlisted).
Returns
bool
visibility
property
Get visibility settings with defaults.
visibility
property def visibility(self) -> dict[str, Any]
Get visibility settings with defaults.
Returns
dict[str, Any]
in_listings
property
Check if page should appear in listings/queries.
in_listings
property def in_listings(self) -> bool
Check if page should appear in listings/queries.
Returns
bool
in_sitemap
property
Check if page should appear in sitemap.
in_sitemap
property def in_sitemap(self) -> bool
Check if page should appear in sitemap.
Returns
bool
in_search
property
Check if page should appear in search index.
in_search
property def in_search(self) -> bool
Check if page should appear in search index.
Returns
bool
in_rss
property
Check if page should appear in RSS feeds.
in_rss
property def in_rss(self) -> bool
Check if page should appear in RSS feeds.
Returns
bool
robots_meta
property
Get robots meta content for this page.
robots_meta
property def robots_meta(self) -> str
Get robots meta content for this page.
Returns
str
should_render
property
Check if page should be rendered.
should_render
property def should_render(self) -> bool
Check if page should be rendered.
Returns
bool
next
property
Get next page in site collection.
next
property def next(self) -> Page | None
Get next page in site collection.
Returns
Page | None
prev
property
Get previous page in site collection.
prev
property def prev(self) -> Page | None
Get previous page in site collection.
Returns
Page | None
next_in_section
property
Get next page in same section.
next_in_section
property def next_in_section(self) -> Page | None
Get next page in same section.
Returns
Page | None
prev_in_section
property
Get previous page in same section.
prev_in_section
property def prev_in_section(self) -> Page | None
Get previous page in same section.
Returns
Page | None
rendered_html
Set rendered HTML.
rendered_html
def rendered_html(self, value: str) -> None
Set rendered HTML.
Parameters 1
value |
str |
toc
Set table of contents.
toc
def toc(self, value: str | None) -> None
Set table of contents.
Parameters 1
value |
str | None |
output_path
Set output path.
output_path
def output_path(self, value: Path | None) -> None
Set output path.
Parameters 1
value |
Path | None |
parsed_ast
Set parsed AST.
parsed_ast
def parsed_ast(self, value: Any) -> None
Set parsed AST.
Parameters 1
value |
Any |
related_posts
Set related posts.
In incremental mode, allow setting on proxy without forcing…
related_posts
def related_posts(self, value: list[Page]) -> None
Set related posts.
In incremental mode, allow setting on proxy without forcing a full load.
Parameters 1
value |
list[Page] |
should_render_in_environment
Check if page should be rendered in the given environment.
should_render_in_environment
def should_render_in_environment(self, is_production: bool = False) -> bool
Check if page should be rendered in the given environment.
Parameters 1
is_production |
bool |
Returns
bool
extract_links
Extract links from content.
extract_links
def extract_links(self) -> None
Extract links from content.
get_load_status
Get debugging info about proxy state.
get_load_status
def get_load_status(self) -> dict[str, Any]
Get debugging info about proxy state.
Returns
dict[str, Any]
from_page
classmethod
Create proxy from full page (for testing).
from_page
classmethod def from_page(cls, page: Page, metadata: Any) -> PageProxy
Create proxy from full page (for testing).
Parameters 2
page |
Page |
|
metadata |
Any |
Returns
PageProxy
Internal Methods 9
_section
property
Get the section this page belongs to (lazy lookup via path).
If the page is lo…
_section
property def _section(self) -> Any | None
Get the section this page belongs to (lazy lookup via path).
If the page is loaded, delegates to the full page's _section property. Otherwise, performs path-based lookup via site registry without forcing load.
Returns
Section object if found, None otherwiseAny | None
—
__init__
Initialize PageProxy with PageCore metadata and loader.
__init__
def __init__(self, source_path: Path, metadata: PageCore, loader: Callable[[Path], Page])
Initialize PageProxy with PageCore metadata and loader.
Parameters 3
source_path |
Path |
Path to source content file |
metadata |
PageCore |
PageCore with cached page metadata (title, date, tags, etc.) |
loader |
Callable[[Path], Page] |
Callable that loads full Page(source_path) -> Page |
_parse_date
Parse ISO date string to datetime (deprecated, use date property).
_parse_date
def _parse_date(self, date_str: str) -> datetime | None
Parse ISO date string to datetime (deprecated, use date property).
Parameters 1
date_str |
str |
Returns
datetime | None
_ensure_loaded
Load full page content if not already loaded.
_ensure_loaded
def _ensure_loaded(self) -> None
Load full page content if not already loaded.
_section
Set the section this page belongs to (stores path, not object).
_section
def _section(self, value: Any) -> None
Set the section this page belongs to (stores path, not object).
Parameters 1
value |
Any |
Section object or None |
__hash__
Hash based on source_path (same as Page).
__hash__
def __hash__(self) -> int
Hash based on source_path (same as Page).
Returns
int
__eq__
Equality based on source_path.
__eq__
def __eq__(self, other: Any) -> bool
Equality based on source_path.
Parameters 1
other |
Any |
Returns
bool
__repr__
String representation.
__repr__
def __repr__(self) -> str
String representation.
Returns
str
__str__
String conversion.
__str__
def __str__(self) -> str
String conversion.
Returns
str