Version Disqus 8.x-1.0-rc3
Drupal 8.2.5

I have a page that is built up of multiple nodes using Twig Tweaks. One of the nodes has the Disqus comment field. Module runs smoothly and everything, however, the Share url is to the node/#### instead of the page.

Tried the following but to no avail:

  1. Updated the Disqus field's default identifier to [current-page:url].
  2. Overrode the node's Disque identifier manually on /node/####/edit page
  3. Tried modifying modules/disqus/js/disqus.js (w/drush cr), so that
disqus_title = document.title;
disqus_identifier = window.location.pathname + window.location.search;

I thought #2 would work above, but it still is tied to the entity's node id. The Share link always goes to /node/####.

Any assistance in this matter would be greatly appreciated.

EDIT: Just noticed that [current-page:url] does not include the search portion of the url. The URL looks like /something/node-title-text-here?page=5

  • I don't want to do modify disqus.js ... I know about not overwriting contrib files. Jan 26, 2017 at 19:20
  • If all else fails I'm going to research how to disable the Share button. Jan 26, 2017 at 21:12

1 Answer 1


So the solution was to add my own Javascript file and just clear the drupal settings for disqus like this:

  1. Added Javascript file to modules/custom/MYMODULE/MYMODULE.libraries.yml
  version: VERSION
    js/disqus_overrides.js: {}
    - core/drupalSettings
  1. Created a new file in modules/custom/MYMODULE/js/disqus_overrides.js

drupalSettings['disqus']['identifier'] = ''; drupalSettings['disqus']['title'] = ''; drupalSettings['disqus']['url'] = '';

  1. Then force this file to be loaded on every page load in modules/custom/MYMODULE/MYMODULE.module (this could be optimized to only load on those pages with the Disqus comment field, but I don't know how yet):

function MYMODULE_page_attachments(array &$attachments) { $attachments['#attached']['library'][] = 'MYMODULE/disqus-overrides'; }

  • I'm not vain and will not accpt my own answer. If someone has a better solution I'll accept theirs. Jan 27, 2017 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.