Why must I run bundle exec jekyll serve after changing _includes to see changes? - jekyll

I have a navigation.html file inside the folder _includes.
After I make any change to this file and reload the page at http://localhost:4000/, I don't see any changes.
But if I go to the terminal, stop serving and then use bundle exec jekyll serve again, the changes are displayed on the browser.
The same does not happen if, for example, I make a change to a post, my index.md or _config.yml. Changes made to these files appear when I reload the browser.
Why does it happen? Is there a way I can fix it?
Note: I'm using the theme jekyll-theme-hacker.

The Jekyll reloader is only triggered by markdown changes. For changes to html or config you have to follow the _turn in off and on_ procedure.

Related

Github Pages - trouble rendering a Page with Jekyll

Whilst using Github Pages I can't get Jekyll to render a contact page.
I am using the following template: https://github.com/antonostrovsky/tale
If I clone the template into a local repo and run bundle exec jekyll serve I get a page with a Contact link that I can successfully follow. The generated _site folder contains a subfolder 'contact' with index.html within it.
I then create an empty repository (https://github.com/antonostrovsky/test_site) at Github and specify this template in _config.yml:
remote_theme: antonostrovsky/tale
The template is successfully rendered, I can see the template on the index page (https://antonostrovsky.github.io/test_site/), and the Contact link leads to nowhere, resulting in "Not Found" error.
Can anyone please help me understand how I can troubleshoot this? Does Jekyll have any debug output that could be placed on a github page?
Does anyone know what could be going wrong?
Thank you in advance
I made a diff between your repo and the template repo and noticed that at some stage you deleted the baseurl property in the _config.yml file.
Forking your repo and re-adding baseurl: "/tale" to the _config.yml file fixes the contact page link for me.
UPDATE:
While the above gets the page working as a fork it doesn't work as a remote template which is what the asker needs.
The test_site has the theme and it builds, however it has no content. There are no pages in test_site repo.
If you copy your contact.md page from the theme template repo into pages/contact.md in the test site repo and then rebuild then your link should now work.
Note: Neither the file nor folder can start with an _ in the test-site repo because it will get skipped over by jekyll.
Tip: Open the dev console and disable page caching then reload to see your changes on github faster. It also helps to add change some page content so that you know you're seeing the most recent version.
To add to the accepted answer and explain this strange behaviour. Pages from the remote theme are NOT included by design:
Custom theme files can be placed in:
assets/allposts.html
with the front matter
---
permalink: allposts.html
---
which results in the
_site/allposts.html
file being generated.
Source: https://github.com/benbalter/jekyll-remote-theme/issues/64

Jekyll - Trying to add images to a post but Jekyll cannot find them

I'm trying to add images to a post but whenever I try to view them in a post (running Jekyll using the 'bundle exec jekyll serve --draft' option when viewing locally) - Jekyll prints the following in the Terminal:
[2019-10-27 20:38:06] ERROR `/blog/jekyll/update/2019/10/_site/assets/ruby_on_rails_image1.jpg' not found.
I'm using the following in my markdown file to add the image to a post:
![Ruby on Rails AWS](../_site/assets/ruby_on_rails_image1.jpg)
I can open the image in Visual Studio Code so I know that the path to the image is correct but for whatever reason, Jekyll can't find it. I've tried viewing the image individually
Does anyone know what I'm doing wrong?
Thanks!
The ../ and _site are causing the issue. Basically, you're telling Jekyll to find the image url in the files after being processed by Jekyll (_site) and where to start looking relative to the blog post (../). To fix, just remove the .. so that the url is ![Ruby on Rails AWS](/_site/assets/ruby_on_rails_image1.jpg)
HOWEVER, relying on the image url after Jekyll processing is not a good idea. Rather, you can tell Jekyll where the image is before processing. Jekyll keeps track of the image and the image's final url. Then it uses that url to get the image. This way you don't care about how Jekyll processes stuff. You can rely on your repo's current structure instead of the structure after processing.
To do that, use the Jekyll link tag: ![Ruby on Rails AWS]({% link path/to/ruby_on_rails_image1.jpg %})
Docs on link tag

Why site.baseurl doesn't work on Jekyll?

i have been trying to create jekyll site and host on git-pages. Localy everything works fine. But on github-pages works only first pages and 10 newest blog post.
But after going to any of other pages like "Blogas" or "Straipniai" every link starts with 'localhost:4000' and naturaly breaks css, javascript...
And i am not sure where is problem, because everything is same even if i make change in /_includes/header.html site.url to site.baseurl.
Here is git-hub
And site
I think the problem is that you somehow have both a .md and an .html version of the same pages. The .html version you built locally and GH is preferring it. it has localhost in the urls so it won't work. Try deleting the .html files in those sub folders and see what happens. For example, delete the index.html file from invisibleghostt.github.io/blogas/ and see if that page is fixed.
No idea how you got those files in there, they should not be there.
Look, there are a few things you'd better fix on your _config.yml:
url: "http://codas.lt" # add the site url
gems: # remove `jekyll` from gems
- jekyll-sitemap
- jekyll-gist
- octopress
include: [".htaccess"] # remove this line (GitHub Pages does not support .htaccess)
The other thing is, you'll need to remove all the folders from the folder _posts, as explained here:
If you organized your categories as
/_posts/code/2008-12-24-closures.md, you will need to restructure your
directories to put the categories above the _posts directories, as
follows: /code/_posts/2008-12-24-closures.md.
You are probably working locally with a Jekyll version which diverges from GitHub Pages' (currently is Jekyll 3.0.3). That's why your site works locally and doesn't work there. To avoid that, build Jekyll with Bundler (a dependency manager). On this answer you can see how to do that, step-by-step.
Hope to have helped! :)
Note: If you get stuck in how to adapt your theme to work with GitHub Pages, you can try GitLab Pages, as you can easily set the Jekyll version you want to use to build your site. For example, this project builds the site with Jekyll 2.5.3.

Why is just the HTML showing after I push my changes from Jekyll to Github Pages?

I am creating a blog on Jekyll for the first time and I am at the point where I'm trying to deploy what I have so far to github pages. When I serve the site and view it locally, it looks fine - so I thought that all I had to do was push all of the files to a gh-pages branch. Now that I have done this, all that is showing is the HTML.
To troubleshoot, I downloaded just the template files and pushed those to a Github page to see if the issue had to do with how I was editing the CSS, but when I did that I got the same results.
I came across an article that was specifically about how to use github pages to store a jekyll site, and it said to remove the slash before the css folder in the linked stylesheets on the HTML if your page isn't styled correctly. After reading that I thought that the slash was for sure the issue, but after removing the slash... I got the same result.
I have been trying for hours and I feel like its probably something very simple(such as the slash).
Here is the repo:
https://github.com/pacalabre/blog-site/tree/gh-pages
Here is the output:
http://pacalabre.github.io/blog-site/
Thank you in advance for any answers!
You need to add/edit:
baseurl: /blog-site
to the config file. Note there is no trailing slash. 'blog-site' is the name of your project, the project name becomes a sub directory that serves your site. Without the baseurl setting, your relative urls are trying to fetch things from http://pacalabre.github.io/ when they are really at http://pacalabre.github.io/blog-site/.
GH is serving your site as a subfolder to the domain and your references are not taking that into account.
Once you add the baseurl setting, you then need to add {{site.baseurl}} in front of your assets like images, css and js.
Also, once you do the baseurl setting, when you serve locally it will not be quite correct, you will need to add the /blog-site to the end of the localhost url for it to work properly.
You also should try using the dev tools inspector in Chrome to help you troubleshoot, it will clearly tell you right now that it cannot load all your js files or images, and it will show where it is trying to load them from.
Look, there's something wrong with your site/repo.
I didn't find your _config.yml at the site root ( gh-pages branch). It should be there.
There's a binary file there (probably Mac's file if I'm not mistaken). It shouldn't be there.
There are both Jekyll's folders (_posts, _drafts, _layouts, etc) and _site folder there. You need to choose. Or you upload the _site content (not the folder itself) or you upload the Jekyll project. Usually you upload just Jekyll folders and GH build the site for you, unless you use some plugins which are not allowed by GitHub. In this case, you upload just the _site content, which is the compiled site (html, CSS, js only).
On the previous answer, you were instructed to add a baseurl to your site configuration. It's the best approach, but if your template uses just url and doesn't even mention baseurl, the best way is adding the project name to the end of the url, not searching for every link to call {{ site.baseurl }} via liquid. So, instead of giving yourself all this trouble, better do like that in your _config.yml:
url: http://username.github.io/projectname
If you indeed go for setting up the baseurl, you can view your site locally via localhost:4000 by adding this flag when serving Jekyll: --baseurl "". So, jekyll serve --watch --baseurl "". This means like "Jekyll, ignore the baseurl set in the config". Got it?
Serving Jekyll with bundler is the right way to do that, specially when deploying to GH Pages. But this is another story, I can add a comment later if you're interested.
Suggestions. Read a little more about how Jekyll works. Also look for .gitignore so you won't upload to GH anything unnecessary (like that binary file).
After that, if your site doesn't build or display correctly, let me know and I'll help you out if you want.
Hope to have helped!

How can I add a downloadable file to my Github.io page?

I have set up my professional website/homepage using Github Pages. I know if this was just HTML being served up from somewhere, my downloadable file would need to be in the directory of my .html file, and then I could reference it in the .html file and link it up. However, since this is served by Github through repository, I am unsure on how to do this.
Do I put my downloadable file in my repo under version control like the rest of the project?
If so, what path do I use in the .html file?
Also, I am aware that the Automatic Page Generator makes it possible to hardly touch the HTML, but it seems pretty restrictive as far as customizing where links and other content appears on your page...
You could just link it normally in your html. Commit it to your repository and have users right click to save.
I just tried this on one of my repositories where I put a link to my CSS file.
style.css
I was able to right click the link and download the file.
If you wanted to create a download from the root you would do:
Download File
I'm pushing my repositories manually instead of using the Automatic Page Generator. The steps are pretty straight forward Creating Project Pages Manually - GitHub Help
Since it is done in GitHub pages. It can also be done like this (in markdown fashion): [download]({{ site.baseurl }}{% link file.txt %}). It has the advantage to work locally without pushing the file to the repo.