Jekyll exclude folder not matches - jekyll

I can't exclude js/ folder for watching without excluding dist/js/ in _config.yml. My folder structure is the following:
- js/
- dist/js/
For some reason if I add js/ to the exclude array, Jekyll excludes both. I need to exclude js/ because it builds twice.
Seems like it searches for all the matches, not just js/. It doesn't even work with /js or /js/.
This is my _config.yml exclude array:
exclude: [js/, node_modules/, Gruntfile.js, package.json]

You don't need to add a trailing slash for folders.
This works fine in Jekyll 3.2.1:
exclude:
- js
- node_modules
- Gruntfile.js
- package.json
include:
- dist

Related

How can I "watch" multiple source directories in Jekyll?

I'm pretty sure I've seen in Jekyll blog projects with multiple source document directories, such as _posts and _pages, but the source parameter in the _config.yml file can only take 1 directory as its argument, and neither an array nor a space separated string of directories works.
Am I misunderstanding the meaning of the source parameter? I'm expecting it to be used by watch to specify which files' changes will trigger a build, and which files to build.
Also, I have fragments such as about.md which can be included in other pages. What is the best location for files like this one?
The source configuration refers to your <project_root>, not individual directories within the project root. By default, its set to your current_directory (the location from where you are running jekyll build (or) serve.
Jekyll watches all nested files and directories deep within the source directory by default.
about.md is not meant to be seen as a fragment to be included in other files. Its a full-blown "page" that would render into _site/about.html or _site/about/index.html depending on your permalink settings.
Fragments to be included in other pages live inside the _includes directory and are inserted via the Liquid construct {% include <fragment-filename>.html %}
Other than _layouts, _includes and _sass, directories that start with an underscore are ignored by Jekyll unless you configure Jekyll to see them as "collections". _posts is a pre-defined and hard-coded collection directory.
For more information on Jekyll, refer the official documentation at https://jekyllrb.com
If anyone, like me, is looking to include several source folders in github-pages, you can simply configure the jekyll root in github-page on the master branch. I.e. not on gh-page branch, nor on the docs folder.
Thus, all folder is processed. README.md are treated as index.md and you can easily make relative links from the main README.md at the root to any other doc which are "below" it in the file hierarchy. Thus having jekyll cover all your code documentation.

Jekyll _config.yml include can't access site

My folder looks like this
my-blog
_includes
_layouts
_pages
contact.html
_posts
_config.yml
index.html
In _config.yml
email: "xxx#yyy"
.
.
.
include: [_pages]
In _pages/contact.html
---
layout: default
title: Contact
permalink: /contact/
---
{{site.email}}
However, it shows "{{site.email}}" but not "xxx#yyy"
Am I able to access "site" in the included folders or files?
Folders that starts with an underscore are special for Jekyll, and unless they are for using something predefined like _data, they will be ignored by Jekyll.
If you rename the _pages folder to pages then Jekyll will process the file and output the email data with the code you were using.

Keep Jekyll output files from permalink generation

I have one page - hello.html. For this page i have two languages which are defined in a config file. Also i have two different output directories configuration, different the original file name - en/ and pl/. Now, i can generate one lang by dedicated config, after this i can do this for second one.
My question is how to keep en/ directory when i'm generating pl/ one and reverse, how to prevent removing them form public output directory?
Using keep_files jekyll config feature is not working because output directory/file name is different then original.
Hope that this is clear enough.
If you don't mind having two config files, exclude the en files in your pl config, and vice versa. For example, in your pl _config.yml:
exclude: ["en"]
In your en _config.yml:
exclude: ["pl"]
From https://jekyllrb.com/docs/configuration/:
Exclude
Exclude directories and/or files from the conversion. These exclusions are relative to the site's source directory and cannot be outside the source directory.
exclude: [DIR, FILE, ...]

Shorten url of sub-folders in Jekyll

I have a Jekyll project that includes a git submodule foobar with some markdown files that need to be rendered in addition to the ones in the main repo. These files have paths like ./foobar/docs/current/module-1.md.
With the current url scheme this means they get the path /foobar/docs/current/module-1.md, but I'd rather have the shorter path /current/module-1.md. Is this possible using the standard Jekyll install that comes with Github Pages?
You can use default configuration values to set permalink for your foobar folder.
In _config.yml, add :
defaults:
-
scope:
path: "foobar/docs/current"
type: "pages"
values:
permalink: /current/:basename

Glob pattern excluding some of the first level directories

I have a folder structure like this
ProjectX
.......|_____node_modules
.......|_____src
.......|_____build
.......|_____app
.......|_____libraries
I have written a glob pattern in grunt browserify something like this
src:['**/*.js','!node_modules','!build'],
dest:'build/build.js'
What i want from above code is, all .js files in my project should be browserified except the .js files in 'node_modules' and 'build' folder.
But what actually is happening is still the files from node_modules and build folder are browserified in my 'build/build.js' destination.
And i do not want to specify folder names of the .js file i require. I do not want to do something like this
['src/**/*.js' ... etc]
How can i solve this problem?