-
Notifications
You must be signed in to change notification settings - Fork 16
[FEATURE] Make templates overridable #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
linawolf
wants to merge
1
commit into
main
Choose a base branch
from
feature/templates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,5 @@ to extend the tool. | |
| Developer/Index | ||
| Redirects/Index | ||
| Migration/Index | ||
| Templating/Index | ||
| KnownProblems/Index | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| .. include:: /Includes.rst.txt | ||
|
|
||
| .. _override-templates: | ||
|
|
||
| ==================== | ||
| Overriding Templates | ||
| ==================== | ||
|
|
||
| By default, the `render-guides` container uses the Twig templates shipped | ||
| with the official TYPO3 Documentation theme. However, you can provide your own | ||
| templates to customize or extend the rendering output. | ||
|
|
||
| This can be done **without modifying the image**, simply by mounting a local | ||
| directory that contains your Twig template overrides. | ||
|
|
||
| .. important:: | ||
|
|
||
| Custom templates are only supported when you build the documentation | ||
| **locally** (for example using Docker or DDEV) or within your **own CI/CD | ||
| pipeline**. | ||
|
|
||
| When your project documentation is built and deployed automatically via the | ||
| **official TYPO3 documentation workflow** (to | ||
| `https://docs.typo3.org <https://docs.typo3.org>`_), custom templates are | ||
| **not supported**. | ||
|
|
||
| The central rendering service uses a fixed, controlled version of the | ||
| official theme to ensure consistency across all published manuals. | ||
|
|
||
| Using Docker to mount a volume with custom templates | ||
| ==================================================== | ||
|
|
||
| When using the official container image, you can mount your custom templates | ||
| directory into the container at the path :file:`/project/custom-templates`. | ||
|
|
||
| For example, if your custom templates are stored in a folder named | ||
| :file:`my-custom-templates` in your current working directory, run: | ||
|
|
||
| .. code-block:: shell | ||
| docker run --rm \ | ||
| --pull always \ | ||
| -v "$(pwd):/project" \ | ||
| -v "$(pwd)/my-custom-templates:/project/custom-templates:ro" \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend to use a separate root path for the templates. Like |
||
| -it ghcr.io/typo3-documentation/render-guides:latest \ | ||
| --progress --config=Documentation | ||
| The container automatically detects the mounted directory and prepends it to | ||
| the template search paths. You can confirm this by checking the container log | ||
| output (when verbose mode is enabled). | ||
|
|
||
| .. tip:: | ||
|
|
||
| You can also use a project-bundled directory named | ||
| :file:`resources/custom-templates` inside your repository. | ||
| If it exists, it will automatically be included as well. | ||
|
|
||
| Directory structure for custom templates | ||
| ======================================== | ||
|
|
||
| Your custom templates must mirror the internal structure of the built-in | ||
| templates that you want to override. | ||
| For example, if the original file is located at: | ||
|
|
||
| .. code-block:: text | ||
| typo3-docs-theme/resources/template/structure/layout.html.twig | ||
| then your custom file must be placed at: | ||
|
|
||
| .. code-block:: text | ||
| my-custom-templates/structure/layout.html.twig | ||
| When both files exist, your version will be used instead of the original. | ||
|
|
||
| Finding the Original Templates | ||
| ============================== | ||
|
|
||
| To create a customized version, you can copy any of the existing Twig templates | ||
| from the image or from your local installation. | ||
|
|
||
| Inside the running container, templates are located under | ||
| :file:`/opt/guides/resources/template`. | ||
| You can inspect or copy them using the following command: | ||
|
|
||
| .. code-block:: shell | ||
| # Example: copy the "singlepage" layout to your custom directory | ||
| docker run --rm -it ghcr.io/typo3-documentation/render-guides:latest \ | ||
| cat /opt/guides/resources/template/structure/singlepage.html.twig \ | ||
| > my-custom-templates/structure/singlepage.html.twig | ||
| Then edit the file locally. The next time you run the container, your modified | ||
| version will automatically be applied. | ||
|
|
||
| Finding the Original Templates | ||
| ------------------------------ | ||
|
|
||
| To create a customized version, you can copy any of the existing Twig templates | ||
| from the image or from your local installation. | ||
|
|
||
| You can open a shell in the container to inspect all available templates: | ||
|
|
||
| .. code-block:: shell | ||
| docker run --rm -it --entrypoint=sh ghcr.io/typo3-documentation/render-guides:latest | ||
| Once inside, you can browse the template directories. | ||
| They are organized as follows: | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 30 70 | ||
|
|
||
| * - **Theme / Purpose** | ||
| - **Location in Container** | ||
| * - TYPO3-specific templates | ||
| - `/opt/guides/packages/typo3-docs-theme/resources/template/` | ||
| * - Bootstrap 5 theme templates | ||
| - `/opt/guides/vendor/phpdocumentor/guides-theme-bootstrap/resources/template/` | ||
| * - reStructuredText (reST) templates | ||
| - `/opt/guides/vendor/phpdocumentor/guides-restructured-text/resources/template/html/` | ||
| * - Base templates (shared core) | ||
| - `/opt/guides/vendor/phpdocumentor/guides/resources/template/html/` | ||
|
|
||
| Example – Copying an Existing Template | ||
| -------------------------------------- | ||
|
|
||
| If you want to customize the basic page layout `layout.html.twig` layout used | ||
| by the TYPO3 theme, copy it from the container into your local project and | ||
| modify it: | ||
|
|
||
| .. code-block:: shell | ||
| docker run --rm -it ghcr.io/typo3-documentation/render-guides:latest \ | ||
| cat /opt/guides/packages/typo3-docs-theme/resources/template/structure/layout.html.twig \ | ||
| > my-custom-templates/structure/layout.html.twig | ||
| Then edit the file locally. The next time you run the container, your modified | ||
| version will automatically be applied. | ||
|
|
||
| If you want to change the output of the the block quotes, you need to override the | ||
| basic template: | ||
|
|
||
| .. code-block:: shell | ||
| docker run --rm -it ghcr.io/typo3-documentation/render-guides:latest \ | ||
| cat /opt/guides/vendor/phpdocumentor/guides/resources/template/html/body/quote.html.twig \ | ||
| > my-custom-templates/body/quote.html.twig | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.