kakawait / hugo-tranquilpeak-theme

A gorgeous responsive theme for Hugo blog framework
https://tranquilpeak.kakawait.com
GNU General Public License v3.0
924 stars 524 forks source link

Unable to load Disqus #241

Closed Brinkhuis closed 6 years ago

Brinkhuis commented 6 years ago

Configuration

Actual behavior

I created a new post on my site brinkhuis.github.io from RStudio with blogdown::new_post("Web Scraping and Visualizing Data from Coolblue") but cannot get Disqus working. It keeps giving the message "We were unable to load Disqus. If you are a moderator please see our troubleshooting guide."

I put my disqusShortname ("https-brinkhuis-github-io") in the config.toml and added brinkhuis.github.io and disqus.com as trusted sites.

baseURL = "https://brinkhuis.github.io"
languageCode = "en-us"
defaultContentLanguage = "en-us"
title = "My Blog"
theme = "hugo-tranquilpeak-theme"
disqusShortname = "https-brinkhuis-github-io"
# googleAnalytics = "UA-123-45"
paginate = 7
canonifyurls = true

Am I missing something here?

Expected behavior

Disqus to be displayed (on page https://brinkhuis.github.io/2017/11/web-scraping-and-visualizing-data-from-coolblue)

Steps to reproduce the behavior

kakawait commented 6 years ago

@Brinkhuis do you configure your baseURL config.toml? (https://gohugo.io/getting-started/configuration/)

Brinkhuis commented 6 years ago

Yes, I did config baseURL in config.toml with value https://brinkhuis.github.io/.

kakawait commented 6 years ago

Ok thank for confirmation.

The only diff I can see from https://tranquilpeak.kakawait.com is about this.page.url

screen shot 2017-11-26 at 19 46 29

where in your case is not an URL but only a path

screen shot 2017-11-26 at 19 48 22

I have to find why, in addition that I'm using .Permalink variable that should be standard/built-in https://github.com/kakawait/hugo-tranquilpeak-theme/blob/master/layouts/partials/script.html#L38

kakawait commented 6 years ago

@Brinkhuis Could you please gimme the hugo cli command are you using to generate? And do you have any errors or warning during generation?

Brinkhuis commented 6 years ago

I generate from RStudio, using the command blogdown::serve_site()

kakawait commented 6 years ago

I'm not a RStudio or Blogdown expert but from what I can see https://github.com/rstudio/blogdown/issues/93#issuecomment-297244046

You should use build_site() instead, as linked comment suggest

Brinkhuis commented 6 years ago

I tried generating with 'build_site()' but that give the same result.

Is there a setting in config.toml to 'correct' my this.page.url value?

Brinkhuis commented 6 years ago

My page now seems right now...

      <script>
        var disqus_config = function () {
          this.page.url = 'https:\/\/brinkhuis.github.io\/2017\/11\/web-scraping-and-visualizing-data-from-coolblue\/';

            this.page.identifier = '\/2017\/11\/web-scraping-and-visualizing-data-from-coolblue\/'

        };
        (function() {

          if (window.location.hostname == "localhost") {
            return;
          }
          var d = document, s = d.createElement('script');
          var disqus_shortname = 'https-brinkhuis-github-io';
          s.src = '//' + disqus_shortname + '.disqus.com/embed.js';

          s.setAttribute('data-timestamp', +new Date());
          (d.head || d.body).appendChild(s);
        })();
      </script>
kakawait commented 6 years ago

@Brinkhuis Now with that code Disqus works for me on https://brinkhuis.github.io/2017/11/web-scraping-and-visualizing-data-from-coolblue/

screen shot 2017-11-26 at 20 17 30
Brinkhuis commented 6 years ago

I see, great! I will add a new post and see if it will also work there...

kakawait commented 6 years ago

About your question, I was answered before you update thread.

Is there a setting in config.toml to 'correct' my this.page.url value?

For Disqus only baseURL and disqusShortname are mandatory and you filled both correctly

Brinkhuis commented 6 years ago

With the setting relativeurls = true in config.toml and using the command blogdown::build_site(local=FALSE) from RStudio everything seems allright!

Thanks for your time and help!

kakawait commented 6 years ago

@Brinkhuis Ok if it's ok for you I will close that issue, feel free to re-open if relevant

Thank you for using Tranquilpeak and have fun