To create social sharing buttons on dynamic template pages (like blog posts) in Webflow, you'll need to use custom embed code that dynamically pulls CMS content (like the current page URL, title, etc.). The method typically involves using Webflow’s CMS fields with custom social share URLs.
Example for Facebook:
<a href="https://www.facebook.com/sharer/sharer.php?u={{wf {"path":"slug","type":"PlainText"} }}" target="_blank" rel="noopener noreferrer">Share on Facebook</a>
slug or relevant field with the Full URL, such as:https://yourdomain.com/posts/{{slug}}.Current URL, give it a unique ID like current-url, and set its display to none.
<script> in the page settings or with a custom Embed under your buttons:
<script>
const currentUrl = window.location.href;
// Set share link to Facebook
document.getElementById("fb-share").href = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(currentUrl)}`;
// Twitter example with text
document.getElementById("twitter-share").href = `https://twitter.com/intent/tweet?url=${encodeURIComponent(currentUrl)}&text=Check this out!`;
</script>
<a id="fb-share" target="_blank">Share on Facebook</a><a id="twitter-share" target="_blank">Share on Twitter</a>
target="_blank" and rel="noopener noreferrer".
To add share buttons on dynamic pages in Webflow: