> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
