I've just noticed on a site that the Disqus comment embed is suggesting other articles but they're adding a token to the end of the URL, for example:


But this returns a 404 in Craft. Works fine without that query string.

Any ideas to resolve?


Not sure why they add this param for you; on my own weblog all the suggested links are without ?token. Maybe you previewed that page and had the Disqus embed showing for the preview as well? Best not to include it for previews and older versions.

Anyway, as explained above by default Craft also uses the 'token' param to preview previous versions of the page. That's probably why it's not working now; this token has expired so Craft can't find any version of that page using the requested token anymore and displays a 404 page instead.

The fix is relatively easy: just change the 'tokenParam' config setting to something else:

Craft v2 - https://docs.craftcms.com/v2/config-settings.html#tokenparam

Craft v3 - https://docs.craftcms.com/v3/config/config-settings.html#tokenparam

Then Craft will just ignore it and show the correct page. Just don't forget to also hide the embed for previews otherwise you will get exactly the same problem soon with the new token param.


Something like this should work to prevent this in the future:

{% if not craft.request.isLivePreview() and not craft.request.getParam( craft.config.get('tokenParam') ) %}
    ... embed code here ..
{% endif %}
  • Thanks for asking this btw. Just found the same bug on one of my other sites and fixed it there the same way. :-) – user155 May 12 '15 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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