---
description: >-
  In this section, you will learn about the process of creating templates to
  optimize content parsing for your website.
---

# Parsing Template

**Now, you can create parsing templates using both visual selection and CSS selectors.** In the 'Template' tab within the Visual Constructor, you'll find a new section called **'Template Patterns'**. This section allows you to define your parsing template using either visual clicks or by directly inputting CSS selectors for precise content targeting. As you visually select elements in the main window, you will see their corresponding CSS selectors automatically populate in the 'Template Patterns' block, giving you a starting point for CSS-based templates.

**Select the Content (Visual or CSS):**

1. **Visual Selection (Default):** In the main window of the Visual Constructor, mark the content you want to include in your parsing template by clicking on the blocks or elements that contain the desired content. The selected block will be marked with a turquoise frame. You can separate different types of content into separate blocks (e.g., text, images, videos) by clicking on them individually. The CSS selectors for your visual selections will appear in the 'Template Patterns' section.
2. **CSS Selector Editing (Advanced):** If you require more fine-grained control or prefer to work directly with CSS selectors, select the **'Save Parsing Template'** checkbox. This action unlocks the **'Template Patterns'** editing fields: **'Elements pattern'** and **'Exclude elements pattern'**.

* **'Elements pattern':** In this field, you can manually enter CSS selectors to define the elements you want to include in your template. **If you edit this field, the elements you selected visually in the constructor will be disregarded.** Therefore, if you are primarily using CSS selectors, you can leave the visual selection step minimal or skip it entirely and directly input your selectors here.
* **'Exclude elements pattern':** Optionally, you can use this field to specify CSS selectors for elements you want to _exclude_ from the parsed content, even if they are matched by your 'Elements pattern'.
* **Selector Syntax:** When editing the pattern fields, separate each CSS selector with a comma. For example: `.article-content p, .article-image>img`.

**Text Content Syntax:** You can also use `textContent` based selectors to target elements based on their text content. For example: `p[textContent^=Read more]` will select all `<p>` elements where the text content starts with "Read more".

**Save the Parsing Template:**

1. **Visual Templates:** If you are primarily using visual selection, ensure the "Save parsing template" checkbox is selected. This option allows you to save the template for future use in automatic parsing from this source. Click on the "Save Template" button to save the parsing template based on your visual selections (or the default CSS selectors generated from them).
2. **CSS Selector Templates:** After editing the **'Elements pattern'** and/or **'Exclude elements pattern'** fields, click the **'Update'** button to apply the changes and save your template. This saves the template based on your manually entered CSS selector patterns.

**Understand Variations in Content:** It's important to note that individual posts, even from the same source, can vary significantly in their structure and content. As a result, the parsed pages may not always contain the exact content you expect, even with a template. Keep in mind that the parsing template provides a structure for extracting content, but there may be variations in the actual content within each post's layout and elements. You may need to refine your template over time to accommodate these variations.

By following these steps, you can create a parsing template in the News Parser plugin to extract the desired content from the source, using either the intuitive visual constructor or the precision of CSS selectors. Remember to adjust and test your template as needed to accommodate any variations in the content structure of the source website.

{% embed url="https://youtu.be/0awSRLWsP-I" %}
