Streaming live at 10am (PST)

Base URL in HTML Embed Code

Hi there,

I have a case where I want to include my website’s current base URL as a field inside of the HTML embed code. This is due to integrating Disqus into my site which requires that I attach a canonical URL to some variable, so it would not be ideal to place a relative URL.

Right now for testing, I have it set as my staging site <staging_site>.webflow.io and that means I would have to manually go through all the embeds to replace them with the live site base URL when publishing the production site.

How can I reference the base URL from the embed code? I can’t seem to find any resources on this anywhere.

Thanks in advance!

Hey @ChengMan

What’s your use case? Are you using this on static or CMS generated pages? If its the latter, you can do as follows;

<script>
var disqus_config = function () {
    this.page.url = window.location.href;
    this.page.identifier = 'YOUR-CMS-PAGE-SLUG';
  };

  (function() {
    var d = document, s = d.createElement('script');
    s.src = 'https://yourdomainname.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
  })();
</script>
1 Like

Hey, @AlexManyeki I’m using this on a CMS generated page. Your solution works great, thank you!

1 Like

Welcome @ChengMan :slightly_smiling_face: