> For the complete documentation index, see [llms.txt](https://news-parser.gitbook.io/news-parser-plugin-v2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://news-parser.gitbook.io/news-parser-plugin-v2/parsing-template/template-options.md).

# Template Options

To create a template for parsing using the news-parser, follow these instructions based on the provided reference information:

1. Begin by creating a template with the following structure:

```json
{
  "template": {
    "className": "[className]",
    "tagName": "[tagName]",
    "searchTemplate": "[searchTemplate]",
    "excludeTemplate":"[excludeTemplate]",
    "elementsTemplate":"[elementsTemplate]"
    "children": [
      {
        "tagName": "[tagName]",
        "searchTemplate": "[searchTemplate]",
        "position": "all"
      },
      // Add more child elements as needed
    ]
  },
  "extraOptions": {
    "addSrcSetAndSizes": false,
    "groupImagesRow": false,
    "addFeaturedMedia": false,
    "addSource": false
  },
  "postOptions": {},
  "aiOptions":{},
  "sidebarSeo":{},
  "userID": "[userID]"
}
```

Replace `[className]`, `[tagName]`, `[searchTemplate]`, and `[userID]` with the actual values for your template.

2. In the template, the `"className"` property represents the HTML class name of the tag that contains the post content. The `"tagName"` property represents the tag name of the tag that contains the post content. The `"searchTemplate"` property is the search pattern used to retrieve the node from the DOM, for example, `"div.pre-center"`. Syntax of "`searchTemplate"`  described  here: <https://simplehtmldom.sourceforge.io/docs/1.9/manual/finding-html-elements/>
3. The `"children"` property is an array of child node elements that contain elements of the post data. Each child element has the same structure as the parent node, with `"tagName"`, `"searchTemplate"`, and `"position"` properties. `"position"` is currently set to `"all"`, indicating that all matching nodes should be retrieved. The child elements are specified in a single array without considering their nesting level.
4. The `"extraOptions"` property allows you to enable or disable additional options for the parsed data. Set the `"addSrcSetAndSizes"` property to `true` if you want to add the `sizes` attribute with image sizes breakpoints. Set `"groupImagesRow"` to `true` to group images in Gutenberg blocks by two and arrange them in a row. Set `"addFeaturedMedia"` to `true` if you want to include a featured media element in the post. Set `"addSource"` to `true` if you want to add a link to the source page at the end of the post.
5. The `"postOptions"` property can be used to specify additional options for the parsed post.&#x20;
6. Finally, replace `[userID]` with the relevant user ID associated with the template.

That's it! You now have a template structure for parsing using the news-parser. Customize the template according to your specific needs and use it with the news-parser to parse data from the provided URL or other URLs that match the template structure.

<br>


---

# 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://news-parser.gitbook.io/news-parser-plugin-v2/parsing-template/template-options.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.
