To create dynamic social sharing buttons in Webflow using custom code, you can use the method where share URLs are constructed with dynamic CMS fields. This allows each CMS item (like a blog post) to generate its own social share links for platforms like Facebook, Twitter, or LinkedIn.
Here’s how to do it using Webflow’s CMS and custom embed code:
In the Embed block, combine static share URLs with dynamic fields using the Add Field (+) button:
Facebook:<a href="https://www.facebook.com/sharer/sharer.php?u={{wf {"path":"slug","type":"PlainText"} }}">Share on Facebook</a>
Twitter:<a href="https://twitter.com/intent/tweet?url={{wf {"path":"slug","type":"PlainText"} }}&text={{wf {"path":"name","type":"PlainText"} }}">Tweet</a>
LinkedIn:<a href="https://www.linkedin.com/sharing/share-offsite/?url={{wf {"path":"slug","type":"PlainText"} }}">Share on LinkedIn</a>
Modify the CMS fields accordingly:
slug
with your full URL field if available.name
with your title field for Twitter text.https://yoursite.com/blog/{{slug}}
).<a>
) in divs or apply Webflow classes directly to the anchor tags.To add social share links on dynamic CMS templates, embed HTML share URLs with Webflow CMS fields injected via the Embed element. Combine dynamic slug or full URL fields to generate share links for Facebook, Twitter, and LinkedIn, ensuring each CMS item generates its own unique sharing link.