Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why put the _site-directory of a Jekyll site in .gitignore?

The documentation of Jekyll tells me, that the _site-directory of a Jekyll site contains the compiled version of the site I have created after running

Jekyll build 

Several articles recommend, that I include the _site-directory in my .gitignore-file because "it just contains the compiled version of my site". (that's what some articles recommend. So, I am not sure if I don't understand some concept of Jekyll or some concept of Git.

If the _site-directory contains the compiled version of a site, shouldn't that be the thing that is on the server the provides the final website? I do understand why you put source code on github and what to do with it, but in the case of github pages, Github is not a versioning system but a file hosting system and the file hosting system should host compiled versions of my work to provide it via MyUsername.github.io to users, right?

My question is: shouldn't it be only the _site-directory of my Jekyll website that I deploy to Github because that should be the compiled source code that github provides to users? So, shouldn't I put anything else in the .gitignore-file EXCEPT the _site-directory?

If I got this all wrong: what is the point in compiling my website via

Jekyll build 

if I don't use the compiled source code for anything?

like image 873
Otterfinger Avatar asked Aug 07 '15 06:08

Otterfinger


People also ask

What is the _site folder in Jekyll?

the _site folder is useful only for local preview of your jekyll site (typically to be found at localhost:4000 by default).

What is Jekyll Git?

Jekyll is a static site generator with built-in support for GitHub Pages and a simplified build process. Jekyll takes Markdown and HTML files and creates a complete static website based on your choice of layouts. Jekyll supports Markdown and Liquid, a templating language that loads dynamic content on your site.


1 Answers

Two solutions :

You don't use Jekyll plugins (or only those supported by github pages)

You build your site only if you need to test it locally (jekyll build or jekyll serve). The generated code (in _site) will not be versioned as github pages will generate pages from the sources.

  • Put _site to .gitignore
  • Push you sources to github pages

You use Jekyll plugins

In this case, you need to build locally because Github pages cannot do the job with plugins.

  • Jekyll build locally
  • Put _site to .gitignore
  • commit your sources in one branch
  • commit your _site in another branch

See this post for more explanations.

like image 104
David Jacquel Avatar answered Sep 28 '22 02:09

David Jacquel