Twitter Share Widget for Current Page URL

The social share isn’t much use in a CMS context if it can’t be configured to share the page you’re on. As is, it looks like you have to hard code the share URL:

Is there a workaround?

Paste this in Site Settings > Custom Code > Footer Code:

<script>
var Webflow = Webflow || [];
Webflow.push(function() {
  var widget = $('.w-widget-twitter iframe');
  widget.attr('src', 
    widget.attr('src').replace(/url=[^&]+&/, 'url='+encodeURIComponent(location.href)+'&')
  );
});
</script>

Give your Twitter widget any valid URL, and it will replace it with the current page URL (only on published site).