Rule: Truncate Value#

This rule allows you to shorten an element’s content to a specified length. It is useful when you need to limit the text length in fields like description, title, or for optimizing display on various platforms.

Extra features#

  • Truncate values to a chosen number of characters
  • When truncating, you can append custom text (for example: “… more on the online store”)
  • Attempts to avoid splitting words and brackets
  • Removes single-letter prepositions and conjunctions at the end

Practical examples#

Example 1: Truncate the description element to 5,000 characters#

This example shows how to truncate text in an element (e.g., description, title, url) to a specified number of characters to meet the requirements for exports or display on platforms.

1. Creating a new rule:

  • Open the “Rules” page.
  • Click the New rule button.

2. Selecting the rule type:

  • In the Rule type field, select the Truncate Value option.

3. Selecting products:

  • In the Query field, choose either All products or create your own Product query for specific products you want the rule to apply to.

4. Choosing the element to change:

  • In the Element field, select the element where you want to write the truncated result.
  • In our case, this will be the description element.

5. Enter the maximum length:

  • In the Maximum length field, enter the desired maximum text length, for example: 5,000 characters.

6. Enter text to append when truncated:

  • In the “When truncated, append…” field, enter the text to be added at the end of the truncated text, for example: “… more information on the website”.
  • This text will be appended but will never exceed the maximum length.

7. Configuring additional options:

  • Avoid splitting words and brackets if possible: This option is enabled by default, meaning the rule will try not to truncate text in the middle of a word or at an inappropriate position.
  • Remove remaining single-letter prepositions and conjunctions: This option is enabled by default and ensures that single-letter prepositions like “a”, “I”, etc. are removed if they end up at the end of the text.

8. Naming the rule:

  • In the last step, enter the rule name, for example: “Truncate description to 5,000 characters”.

Additional uses#

  • Truncate product name length to 150 characters.
  • Truncate URLs for Heureka to a maximum of 300 characters.

FAQ#

What is the Truncate Value rule for?#

This rule allows you to shorten the text length in any element to a chosen number of characters. It is used, for example, for adjusting:

  • overly long product descriptions,
  • names (title) for comparison shopping engines,
  • URL addresses or meta descriptions,

to meet the limits of a specific platform (e.g., Heureka, Google, Zbozi.cz, etc.).

Can I append text when truncating, such as “… more on the website”?#

Yes. In the “When truncated, append…” field, you can enter any text (e.g., ... more on the online store). This text is automatically added at the end of the truncated text, without exceeding the maximum length you set.

How does the “Avoid splitting words and brackets if possible” option work?#

This option is enabled by default. When truncating, Mergado automatically checks to avoid splitting a word in the middle or cutting off a bracket. The result is more readable text even with length restrictions.

What does the “Remove remaining single-letter prepositions and conjunctions” option do?#

This feature removes single-letter prepositions and conjunctions (e.g., a, I) if they would remain at the end of the text after truncation. The result then looks more natural and visually cleaner.

How do I specify the maximum text length?#

In the “Maximum length” field, enter the number of characters the text should not exceed – e.g., 5000. Spaces and appended text (e.g., ... more on the website) are also counted.

What happens if the text is shorter than the set limit?#

If the text does not exceed the specified number of characters, the rule is not applied and the element value remains unchanged.

Can this rule be used to truncate URL addresses or HTML code?#

Yes, but with caution. Truncation is applied purely based on text length, not HTML or URL structure. If you truncate HTML or a link at a bad position (e.g., in the middle of a tag or URL), it may result in a broken link. 💡 In these cases, we recommend combining the Truncate Value rule with the Find and replace rule, which removes entire text parts more safely.

Can I use this rule to truncate product names for certain queries?#

Yes. Simply create a Product query (e.g., products with long names) and apply the rule only to this query. You can, for example, limit names only for a certain brand or product category.

Can the rule truncate by words instead of characters?#

No, currently truncation is only possible by number of characters. If you need to edit text by structure (e.g., remove a sentence or block), use a combination with the Find and replace rule or Regular expressions.

What if I want the text to be truncated automatically only during a certain period (e.g., during a campaign)?#

Use the Timer feature at the bottom of the rule page. You can set specific days and hours when the rule should apply, or limit its validity to a specific date range.

How do I verify that the text was truncated correctly?#

After saving and applying the rules or after regenerating the feed, you can check the result in the product preview or using the Rule walkthrough feature. You will see exactly how the text was truncated and whether the appended text (e.g., “… more on the website”) was added.

Can the rule be combined with other rules?#

Yes, it is very often combined with:

  • Find and replace – for removing unnecessary parts of text before truncation,
  • Rewrite – for subsequently adding text or formatting.
🇨🇿 🇬🇧 🇩🇪 🇭🇺