> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/advanced-template-logic/build-reusable-templates.md).

# Build Reusable Templates

Components are sub-templates that contain page sections that can be merged into a parent template.

## How are they used?

Components allow for a more modular template design scheme:

* Render larger sections of content through **conditional logic** while keeping the parent template easy to read
* Reuse document sections across **multiple parent templates**
* Repeat a formatted section of content as a **list or table** using a Component Query

## Template Formats

### Component

#### HTML-based

* Edit the template in the Template Editor
* HTML-based parent template formats: PDF, HTML, DOC

#### Body-only

No headers/footers, page or email configuration; this is determined by the parent template.

### Component (DOCX)

#### DOCX template file

* Edit the template in Word or other DOCX editor using DOCX syntax
* Only intended for DOCX parent templates

#### Body-only

* Only include a body in the template file

### PDF-Upload

*There is no component version of this format but it can be used like a Component template*

#### PDF only

* Edit the template in the PDF-Upload editor
* Can only be merged into a PDF parent; no type of component can be merged into a PDF-Upload template.

#### Body-only

Configuration of document or email options in a PDF-Upload component will be ignored when merged into a parent PDF.

## How to include components

### The Template Merge Field

HTML-based: `{{{{!YourTemplateNameHere}}}}`

DOCX: `[{{{{!YourTemplateNameHere}}}}]`

PDF-Upload: `{{{{!YourTemplateNameHere componentType="pdf-upload”}}}}`

You can add your Component-type template through the **Insert Field** tool from the *Other Templates* tab:

This method works best when your Component’s base object matches your parent template’s base object.

### The Component Query

To build a table or list with sections repeating for each result in a SOQL query, use a Component Query.

### Dynamic Components

To dynamically reference and render components in templates, use the following syntax:

`{{{{!{{!FullName}} Component}}}}`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.sdocs.com/sdocs/advanced-template-logic/build-reusable-templates.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
