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.
Related
How to set up/embed github profile or github repository cards on your Jekyll personal website?
I am expecting to embed my personal projects from github in the form of widgets on my personal website.
I don't see a direct way to include data in static Jekyll HTML files.
But there are options:
GitHub offers a JSON API for repos and users. Not sure what profile information you're looking for.
Jekyll has data files in YAML where you can store this data and read information from.
My initial idea is to get data in JSON and convert it to YAML, manually or programmatically. Then, you can build a Jekyll site that reads the information from the YAML files.
You can try out the manual way:
Read data from https://api.github.com/users/cadamini/repos using https://reqbin.com/
Convert the resulting JSON file using https://www.json2yaml.com/
Put the resulting YAML file in your Jekyll instance, e.g in _data/github/repos.yml (exclude the hyphens).
Extract:
- id: 540417594
node_id: R_kgDOIDYeOg
name: add-theme-github-pages-demo
full_name: cadamini/add-theme-github-pages-demo
private: false
Use the following code/syntax to access the information:
{% for item in data.github.repos %}
{{ item.name }}
{% endfor %}
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 have a _posts folder that contains all my posts for my blog and projects. I'd like to separate the markdown files for my blog notes and project pages. For example, in addition to the built-in md -> HTML conversion for files in _posts, I'd like to have a _projects folder that contain my markdown files for individual project write-ups and build them into HTML when running jekyll serve.
just define a collections key in your _config.yml:
collections:
projects:
output: true
Official docs for more info..
Looks like you want to use categories. Here is a link discussing a similar problem : Multiple _posts directories
By default Jekyll will ignore new folders with an underscore prefix, so you can't use _projects.
You can separate _posts in several folders, to have all your project files in a specific folder, create projects/_posts folder structure and move your project files inside projects/_posts, leaving blog posts in _posts.
Jekyll will generate each post and automatically assign the project category to them, so you can also generate different lists from your blog posts.
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
What if I want it to write the collection documents to /m/some_subdir/some_doc.html, for instance, but keep the collection name as my_collection?
The documentation says:
If you’d like Jekyll to create a public-facing, rendered version of each document in your collection, set the output key to true in your collection metadata in your _config.yml:
collections:
my_collection:
output: true
This will produce a file for each document in the collection. For example, if you have _my_collection/some_subdir/some_doc.md, it will be rendered using Liquid and the Markdown converter of your choice and written out to /my_collection/some_subdir/some_doc.html.
But gives no option for configuring that.
You should add the following in your _config.yml file:
collections:
my_collection:
output: true
permalink: /m/:path/
Simply permalink: "m" is not enough.
And you should update to Jekyll 2.1.0.