HTML Content
Turn structured HTML and Twig files into complete, navigable application content.
HTML Content is a repository-backed Core App for presenting anything from a single page to a deeply nested documentation site. It combines file-based content, context-aware routing, hierarchical navigation and optional localization without requiring a dedicated controller for every page.
Build entire content experiences
HTML Content can render complex HTML structures and Twig templates. A page may contain headings, Bootstrap layouts, cards, tables, diagrams and other presentation elements. Its directory hierarchy mirrors URI slugs, making large content collections straightforward to organize.
APPNETOS Docs itself uses an extension of CoreApp\Content\HtmlContent to present its
documentation. Individual documentation pages live in a repository directory, while the Core App
resolves the requested page and renders it with a sidebar.
Repository layout and page resolution
The configured content path points to a repository directory. Requested slugs resolve below its
content/ subdirectory. For example, the slug
core/apps/content/html-content maps to the matching nested folder.
appnetos-docs/docs/
├── sidebar.php
└── content/
└── core/
└── apps/
└── content/
└── html-content/
└── global.twig
The loader checks the current content language, then the configured base language, then
global. For each language it checks .html before .twig. HTML
is read directly; Twig is rendered through the APPNETOS template loader. This is a page-file
fallback mechanism, distinct from the 81-language translation catalog available to Core Apps that
need translations.
A sidebar.php is loaded from the nearest matching directory, walking upward toward the
configured content root. This supports a shared global navigation and specialized navigation in
subsections.
Important: use context-aware links in nested Twig pages
When linking between nested pages, use Twig and prefix internal links with
{{ context_url }}. Relative links such as href="core/apps"
depend on the browser's current URL and may resolve to the wrong nested location. The context URL
provides the correct application-context base.
<a href="{{ context_url }}/core/apps/content/html-content">
HTML Content
</a>
For example, the same link remains valid from an overview page or a deeply nested documentation page.
A plain .html file is returned without Twig evaluation; use .twig when you
need context_url, translations or other template expressions.
Sidebar navigation is handled separately: sidebar entries use slugs, and the Core App converts them into context-aware URLs automatically.
Real integration: APPNETOS Docs
The documentation application extends the Core App with only two overrides:
namespace AppnetosDocs\Docs;
use CoreApp\Content\HtmlContent as CoreAppHtmlContent;
class HtmlContent extends CoreAppHtmlContent
{
protected function getRespondNotFound(): bool
{
return true;
}
protected function getContentPath(): string
{
return 'appnetos-docs/docs';
}
}
getContentPath() selects the documentation repository. getRespondNotFound()
enables an HTTP 404 when the requested page does not exist. This is disabled in the shared Core App
by default because other Apps attached to the same URI may resolve additional slugs independently.
Override methods
| Method | Purpose |
|---|---|
getContentPath(): string |
Repository-relative directory containing the sidebar and content tree. |
getRespondNotFound(): bool |
Choose whether a missing page triggers HTTP 404; default is false. |
getContentLanguage(): string |
Current page-file language identifier; default is en. |
getBaseLanguage(): string |
Fallback page-file language identifier; default is en. |
getBaseTemplate(): string |
Replace the wrapper Twig template that presents the sidebar and content. |
__invoke(): ViewSlot|string|null |
Resolve slug, content and sidebar and render the wrapper; normally inherit this behavior. |
As with other Core Apps, presentation templates can be replaced to match an application's design. APPNETOS Core Apps maintain Bootstrap-versioned template variants for supported framework versions.
Sidebar structure and navigation
The sidebar is a trusted PHP file returning a navigation array. It can define a title, favicon and
nested menu entries with title, slug and children. Dividers
use ['divider' => true]. The Core App recursively resolves navigation URLs, marks
the current entry active and expands branches containing the active page.
<?php
return [
'title' => 'Documentation',
'menu' => [
[
'title' => 'Core Apps',
'slug' => 'core/apps',
'children' => [
[
'title' => 'HTML Content',
'slug' => 'core/apps/content/html-content',
],
],
],
],
];
Content and sidebar PHP files must be trusted repository files. The Core App validates slug segments and resolved paths to prevent traversal outside the configured content directory.
Related documentation
See Content Core Apps for the category overview and App Content for the underlying APPNETOS content model.