Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sidenote / newthought liquid tags cause problems on github pages? #69

Open
jannieuwenhuis opened this issue Apr 18, 2020 · 16 comments
Open

Comments

@jannieuwenhuis
Copy link

Hi, this jekyll theme looks amazing when I run it locally, however on github pages a blog with this theme won't compile for me due to recurrent issues with sidenotes and newthought tags in liquid in sample posts but also in the index file.

@clayh53
Copy link
Owner

clayh53 commented Apr 18, 2020 via email

@shoaibkhanz
Copy link

Thansk a lot for this, I was able to deploy it. However, there is one problem I get into. i.e. disqus comments. When I publish the site locally I can see that the html produces disqus code and I see my disqus comments section.

The problem is that when rake automated script produces the site (ready to be pushed to gh-pages) it ignores the disqus code and I am not sure why that happens.

I have essentially used the below code and its stored in _includes/disqus_comments.html

{% if page.comments != false and jekyll.environment == "production" %}

  <div id="disqus_thread"></div>
  <script>
    var disqus_config = function () {
      this.page.url = '{{ page.url | absolute_url }}';
      this.page.identifier = '{{  site.disqus.shortname  }}';
    };
    (function() {
      var d = document, s = d.createElement('script');
      s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
      s.setAttribute('data-timestamp', +new Date());
      (d.head || d.body).appendChild(s);
    })();
  </script>
  <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
{% endif %}

next I mention the following inside the post.html

{% if site.disqus.shortname %}
  {% include disqus_comments.html %}
{% endif %}

@clayh53
Copy link
Owner

clayh53 commented May 9, 2020

I looked at the rakefile and I can't see anything immediately obvious that would cause this to happen. It makes me wonder if it is happening in the build stage. Your template has an 'and' logic in the include. Is it possible that one or both of the conditions are not being met when it is being built for production? Perhaps the jekyll.environment variable is not being set during the build step for the rakefile. How are you building it locally? Are you setting the environment variable on the command line with the jekyll command? If that is the case, maybe editing the Rakefile to add that command line switch to the build task. I'm just spitballing here.

@shoaibkhanz
Copy link

yeah that was it. , I went from this
{% if page.comments != false and jekyll.environment == "production" %}
to
{% if page.comments != false %}

Thanks a lot!

@knautschzone
Copy link

Thanks a lot for this awesome theme! Unfortunaly I'm unable to get it working on github-pages. I'm running into the same error jannieuwenheuis mentioned. The building-process allways fails because of the unknown licquid-tags within the .md files even when following your instructions using rake. Locally there are no problems at all. Any more advice?

@clayh53
Copy link
Owner

clayh53 commented Jan 1, 2021 via email

@knautschzone
Copy link

Thanks for your fast response! Pushing to master works fine for me. I just cloned your repository, using "bundle exec jekyll build/serve" works perfect and "rake" also creates the gh-branch, but hosting on GitHub Pages (gh-pages/root) runs into the described error. The gh-branch however does not include any _site-folder (the same is true for the master-branch because of the gitignore-file I'm assuming). Does this help?

@clayh53
Copy link
Owner

clayh53 commented Jan 1, 2021 via email

@knautschzone
Copy link

Thanks again for the fast answer! Just looked at your repo and realized: My gh-pages branch (which was created by the simple ""rake"" command) looks exactly like the master-branch, while your is identical to what is in the _site-folder of when I build the page locally. This seems to be the problem but I don't know how to fix it.

@clayh53
Copy link
Owner

clayh53 commented Jan 1, 2021 via email

@knautschzone
Copy link

knautschzone commented Jan 1, 2021

The command you gave ""rake UploadToGithub.Rakefile"" seems to do nothing in my setup. I was running just ""rake"" before which created gh-branch and reached "yolo", switched branches (from master to gh-pages and back) and once printed "fatal: paths 'updated\ ...' with -a does not make sense".

Edit: small update: when I manually push the content of the _site folder to gh-pages it works. It seems to be a problem with the rake-file not working properly on my machine. Thanks again for your patience and help!

@clayh53
Copy link
Owner

clayh53 commented Jan 1, 2021 via email

@knautschzone
Copy link

Thanks for the commenting of the rakefile. Working on windows here. Maybe I have to write a small script myself, but for now seeing it work after manually pushing the site-folder is fine. Thanks again for your support. I appreciate the patience with a rookie like me!

@clayh53
Copy link
Owner

clayh53 commented Jan 2, 2021 via email

@joshjacobson
Copy link

From above:

for the links to work, set your baseurl in _config.yml to your repository name for this project. For instance, perhaps your repo name is jan-nieuwenhuis. Then when you build and test locally, use a command line switch to change the baseurl back to nothing like this:

From ReadMe:

Set this to your own project name if you're going to serve your site from Github Pages. Be sure to include the leading slash, and no trailing slash. For example: /my-project-name

For a full explanation of setting your baseurl to work with Github Pages, see the Project Page URL Structure section of the Jekyll documentation.

To serve from anywhere else besides Github Pages, use a blank baseurl in your _config.yml file:

I'm serving from Github Pages, and following these instructions failed for me. Using a blank baseurl is what succeeded for me (both for index.html successfully looking for CSS in the right location and top nav).

@Saptam04
Copy link

Thanks for the commenting of the rakefile. Working on windows here. Maybe I have to write a small script myself, but for now seeing it work after manually pushing the site-folder is fine. Thanks again for your support. I appreciate the patience with a rookie like me!

Faced the same issue. After wasting a whole day, and visiting a couple hundred stackoverflow posts what I realised is the following: Windows sucks big time. None of the commands in the Rakefile worked (strangely, none of them raised an error or warning). To make the script work you need to make a couple of non-trivial changes. First, Windows cares way too much about quotes in the directory path, so need to be careful about it (the git commit -am #{message.shellescape} line is the cause of that strange fatal: paths ... with -a does not make sense error). Second, since the Unix commands don't work, we need to substitute them with Windows' own commands. Following is the content of the Rakefile after addressing the issues.

require 'rubygems'
require 'rake'
require 'rdoc'
require 'date'
require 'yaml'
require 'tmpdir'
require 'jekyll'

desc "Generate blog files"
task :generate do
  Jekyll::Site.new(Jekyll.configuration({
    "source"      => ".",
    "destination" => "_site"
  })).process
end


desc "Generate and publish blog to gh-pages"
task :publish => [:generate] do
  Dir.mktmpdir do |tmp|
    system "robocopy _site #{tmp} /E /MOVE > nul"
    system "git checkout -B gh-pages"
    system "git rm -rq *"
    system "robocopy #{tmp} . /E /MOVE > nul"
    message = "Site updated at #{Time.now.utc}"
    system "git add ."
    system "git commit -am \"#{message}\""
    system "git push origin gh-pages --force"
    system "git checkout master"
    system "echo yolo"
  end
end

task :default => :publish

Whew! Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants