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
Related
I'm trying to define defaults in multiple config files, for the sake of organization and not having a huge config file. From what I can tell it doesn't work and the documentation doesn't mention anything about it but wasn't sure if I was missing something.
Here are both the config files:
_config.yml
defaults:
- scope:
path: ""
values:
value1: "Value1"
_config2.yml
defaults:
- scope:
path: ""
values:
value2: "Value2"
Here is an HTML file in the default directory
---
---
<p>{{ page.value1 }}</p>
<p>{{ page.value2 }}</p>
And here is the build command
jekyll build --config "_config.yml,_config2.yml"
With all of that, building the project generates the following for index.html
<p></p>
<p>Value2</p>
Even with changing the scopes it has the same result. It seems as though defining defaults in another config file will completely override defaults in the previous file. Is there a way to make something like this work?
The docs say:
Specify config files instead of using _config.yml automatically. Settings in later files override settings in earlier files.
In your case the default's scope.path is the key, and the values are overwritten because the scope.path is identical in both config files. If you changed the path in one file you should see both values appear.
Since I list all my posts in one page called fotos.html I don't need the individual posts to appear as HTML files in the _site output directory. How can I tell Jekyll to not output the .md posts in the _posts directory as individual HTML files?
[
E.g. The contents of Firmwochenende.html are present in fotos.html with properly formatted title and date. Firmwochenende.html includes only photos and nothing else, which is not useful at all.
I build using build exec jekyll serve and host on Github Pages: https://github.com/junge-pfarre/junge-pfarre.github.io
These are the relevant parts of _config.yml:
defaults:
- scope:
path: ""
values:
layout: "default"
- scope:
path: "assets/flyer"
values:
flyer: true
markdown: kramdown
permalink: :title
A simple post has these contents:
---
title: Jugendandacht Gründonnerstag
---
![Altar der Josefskapelle in der Pfarrkirche Baden St. Stephan][1]
[1]: {{ site.baseurl }}{% link /assets/fotos/Jugendandacht2018.jpg %}
You'll need to use a custom collection rather than the default as the _posts collection is, by design, always going to output individual files. If you create a new collection, you can specify output: false for that collection in your config file while still being able to iterate through it and display the content. From the Jekyll documentation:
# Config file
collections:
your_collection_name:
output: false
However, I saw that you mentioned pagination in the comments. I don't believe GitHub currently supports a gem that has pagination functionality for collections other than _posts (like jekyll-paginate-v2, though they're in talks on merging this in eventually). In the meantime, it looks like there are some solutions out there to help with this limitation.
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.
I'm trying to do this because I'm using a CMS where users will be able to edit a data file to make changes to the page instead of the _config.yml.
I'm wondering if it's possible to reference a variable from the data file and place this reference within the _config.yml.
Here's an example of what I'm trying to do;
Data File (/_data/site-data.yml)
navigation:
navigation_colour: '#462634'
Config File (/_config.yml)
defaults:
-
values:
navigation:
navigation_colour: site.data.site-data.navigation.navigation-colour
Is something similar to this possible?
Thanks!
You can assign at least in one config-file variables, I have not tested this over multiple files.
Variables inside YAML
YAML, hello will become Greetings earthling!
something: &hello Greetings earthling!
myref: *hello
MARKDOWN
{{ site.data.samplelist.myref }}
Jekyll does not parse variables in _config.yml. However inside your blog you can use liquid tags like {{site-data.navigation.navigation-colour}}. See here.
If its mandate to replace variables in _config.yml then use a custom or standard replacement plugin with grunt. So effective grunt build task will first perform token replacement in _config.yml and then do jekyll build.
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, ...]