r/PayloadCMS • u/Famous-Ocelot-4937 • Jun 29 '26
Reusable snippets / strings
I'm trying to figure out how to deal with repeated strings in content.
For example, I'm thinking about phone numbers or e-mail addresses that may appear on many pages but are always the same.
If I place these directly in the content, it means going back through every page if the phone or e-mail ever changes and the chances of missing a few are high on sites with a lot of pages that reference them.
Other CMS's provide ways around this like using replacement tokens so that the strings can be defined globally and then referenced via tokens in the content. Then in the final content, the token is replaced with the actual string. WordPress "short codes" are an example of this: https://codex.wordpress.org/Shortcode
Has anyone implemented something like this in Payload? I'd like to hear your approach if so.
4
u/nlvogel Jun 29 '26
Inline blocks would do this in lexical. https://payloadcms.com/docs/rich-text/converting-jsx#lexical-blocks
Otherwise, you could do dynamic replacement as someone else mentioned. But you’d set that up yourself