-
Notifications
You must be signed in to change notification settings - Fork 17
[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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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 | ||
|
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. What exactly does that mean:
If it's the later, it would clutter the repository. If the first, atleast i tried and did not get it to work as expected. with neither of the commands |
||
| :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 \ | ||
|
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 get the error, that cat is not defined in the container: Result of the command |
||
| 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 | ||
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.