Webflow sync, pageviews & more.
NEW

Can text entered in the Webflow CMS be automatically truncated once added to a page? For example, using the first 100 characters of a field as the snippet text on a directory page?

TL;DR
  • Bind the CMS text to a Text Block in Webflow to display full content.
  • Add custom JavaScript using a unique class to truncate text to a set character limit on page load.

Yes, Webflow CMS text can be automatically truncated on a page, but it requires a combination of Webflow's native CMS bindings and a bit of custom JavaScript, because Webflow does not currently provide native character-limit truncation for CMS content directly.

1. Use Webflow CMS Binding for the Full Text

  • Add a Text Block to your Collection List Item in the page.
  • Bind it to the CMS Rich Text or Plain Text field you want to truncate.
  • This will display the full text by default.

2. Set a Character Limit with Custom JavaScript

  • You’ll need to use a JavaScript snippet in your page’s Footer Custom Code settings to truncate the displayed text.
  • Assign a unique class (e.g., .truncate-snippet) to the text block you want to limit.
  • Then use a script that runs on page load to cut the text after a specific number of characters (e.g., 100), such as:
  • document.querySelectorAll('.truncate-snippet').forEach(el => { el.textContent = el.textContent.slice(0, 100) + '…'; });

3. Customize for Word-Boundary or Conditional Behavior (Optional)

  • If you want to avoid cutting in the middle of a word, modify the script to truncate at the last space before the 100th character.
  • You can also write logic to only truncate if the text is longer than 100 characters.

Summary

Webflow CMS does not support character-based truncation natively, but you can achieve this using a CMS-bound text block combined with custom JavaScript to display a substring (e.g., the first 100 characters) for preview or snippet purposes.

Rate this answer

Other Webflow Questions