In my Jekyll page I have huge collections that take 35s to render and sometimes I just delete the biggest folders to iterate faster but I figure it should also be possible to have a secondary _config.dev.yml that undoes the _config.yml's collection definition. But I fail to get it to work.
How do I get jekyll to disregard a folder that is configured for a collection in _config.yml?
To have Jekyll pretend folders to be empty, simply exclude these folders in your _config.dev.yml:
exclude:
- _bigCollection
- _otherBigCollection
You could do it the other way round:
Do not define the collection in _config.yml.
When you deploy your site to production (or when you do want to render the big collections locally), use a secondary _config_with_collections.yml which includes just the collection definitions.
Related
I want to prepare a newsletter archive page, using the Jekyll and github pages. Each edition has several content categories. I however intend to use pages instead of posts, as all posts would have the same date. The page category should be set by folder structure.
My plan was to have each edition as a collection with subfolders, which would assign the category tag:
root
\_edition1
\cars
\Skoda.md
\Volvo.md
\boats
\BoatyMcBoatface.md
\QueenElizabeth.md
\_edition2
\cars
\Trabant.md
\Volvo.md
\boats
\BoatyMcBoatface.md
\LittleBoat.md
The question is, how to assign category by directory structure to pages in collection?
I suppose this is a common use case, however even jekyll homepage use a workaround (manually build index with custom categories in _data section). Could this functionality be somewhat automatically generated by folder structure?
Thanks for any comments!
I've been playing around with Jekyll lately and recently discovered that S3 wouldn't allow me to have enough buckets to have one bucket per website.
So I'm struggling to figure out two things
1) How do I specify that I want a 'child' subdirectory to be created, and all the generated website's files to be in it ?
2) How do I use a variable as the 'child' subdirectory's name ? (since it will be different for each website)
The baseurl config option doesn't seem to do anything about that. Any idea will be welcome :-)
Thanks a lot, and have a great day !
I'm not sure about the variable option, however, for child sub-directories:
A) If you can put the content into "child" folders directly within the jekyll content, then use different configuration files to manage each site through build properties. See the examples under the example below.
B) If you just want to put the same content in different places, perhaps you could use different baseurl or destination properties in different config files? Use the same config file approach as below, but with different versions of those properties instead of/in combination with the exclude property (see https://jekyllrb.com/docs/configuration/#serve-command-options).
Example: Use different config files
Use the exclude config property to exclude folders (and all of that folder's contents) when running a build. You could also specify different output folder locations per site, base URLs, and so on. I'll focus on the exclude property, but you can find other useful properties in the documentation: https://jekyllrb.com/docs/configuration/#global-configuration
For example, you could have the following files/folders:
/siteA-folder/siteA-content/blah.html
/siteB-folder/siteB=content/meh.html
/siteC-folder/siteC=content/foo.html
config.yaml
config_buildA.yaml
config buildB.yaml
Use the build option --config FILE1[,FILE2...] (https://jekyllrb.com/docs/configuration/#build-command-options) to explicitly call your custom config file A or B, each of which has its own version of the exclude property.
Snippet from config_buildA.yaml:
exclude:
- /siteB-folder/ # While building A, you want to exclude the siteB folder and contents
- /siteC-folder/ # Similarly, exclude siteC contents
Snippet from config_buildB.yaml:
exclude:
- /siteA-folder/ # While building B, you want to exclude the siteA folder and contents
- /siteC-folder/ # Similarly, exclude siteC contents
Building A from the command line:
jekyll build --config config_buildA.yaml
Building B from the command line:
jekyll build --config config_buildB.yaml
By managing excludes in the config file, you can re-use the common templates and css, and keep everything together (using less disk space overall).
If there's shared content, you could also look into using a more advanced feature, includes (see https://jekyllrb.com/docs/includes/), to manage the shared content in the includes folder, referenced within the html or markdown files (but that's getting a little of the beaten track for your question, so I'll stop there...)
EDIT: I see you've edited the question specifying the baseurl property doesn't do what you're looking for.
I've used a combination of the url site property baseurl and destination similar to below. In my case, I have different destinations depending on whether it's an archive or latest content, but you could use this to build to different web folders if you wanted.
Ex: config for latest content
url: http://example.com
baseurl: "/latest/"
destination: /path/to/latest/output/
Ex: config for archived content
url: http://example.com
baseurl: "/archive/content/"
destination: /path/to/archive/output/
Then, using the multiple versions of the config file, I can just call whichever one applies.
I would like to collect only the depending partials of a single template. Or otherwise ignore unused partials. Because it is a large project with lots of templates/partials and dependencies it is not possible to do that by hand.
Example file and folder structure would be something like:
/sites/foo.hbs - includes {> partial1}
/sites/bar.hbs - includes {> partial2}
/partials/partial1.hbs
/partials/partial2.hbs
Now I would like to precompile foo.hbs only. For precompilation i have to configure foo.hbs as root and /partials/*.hbs as partials.
The precompilation should end up with the content of foo.hbs and partial1.hbs in a single file.
Is that possible with handlebars at all? Maybe with an existing gulp plugin?
Your question contains a (somewhat) logical error.
Partials were initially intended to act as separate templates.
I guess your intentions are basically more syntactic sugar'ish,
- as you wish to write your code separately though merge it on deployment (some people call that OCD, since it has no real benefit in terms of performance).
Anyhow.
You can run a node scripts that runs through your HBS's, locates partials, extracts them into their parent elements and outputs these final templates.
Take a look at this following answer -
find files by extension, *.html under a folder in nodejs
When I try to click on some function in PhpStorm with a CRTL button the system tries to bring me to a definition of this function. Sometimes there are multiple definitions and the annoying page shows up telling to chose to which definition you want to go. Like here:
Because I am using grunt and minifing / concatenating results, the definitions is in multiple places. I know that I should ignore everything in node_modules, but the system does not. Is there a way for me to exclude some of the folders?
If you don't need any completion/navigation/etc. from your local node_modules, you can exclude this folder from your project:
right-click, Mark directory as/Excluded
You will still be able to run Grunt, but files in these folders won't be indexed and thus suggested for completion/navigation
In Jeky'll's _config.yml file I have the following at the bottom: exclude: README.md, css/config.rb
It excludes the README fine, but not the config.rb file. What am I doing wrong?
This is a problematic feature of Jekyll for quite some time.
Just to be sure: what version of Jekyll are you using? The latest ones enforce correct YAML handling, so you should be using the array syntax (exclude: [README.md, config.rb]).
It's possible with the current implementation to use glob syntax and exclude a whole directory (or tree of directories or whatever), but I couldn't find an issue or documentation on how to exclude a specific file in the filesystem.
In any case, you can exclude config.rb. I assume you don't have another one in your site, and even if you have, you probably don't want it to be on _site. This is bad overall, but works. Your exclude rule would be exclude: [README.md, config.rb].