Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organize multiple outputs inside a single Jekyll project?

I use Jekyll to create documentation for software products. I have 30 + different products that have a common LIQUID template but different content. Every single product documentation has its own table of content.

For one project, everything is OK. I have a content folder as well as css/js folders. I run "jekyll serve" and publish a project.

The problem is that, I do not want to have 30 Jekyll projects stored one next to another with similar css, configs, js folders and will only differ in content part.

The question is: how can I organize the internal structure so I have a single project with a common layout and 'x' different content folders inside the single project?

Like:

_product1/

  • some_subdir

    'topic.md'

_product2/

  • some_subdir

    'topic.md'

If it's possible, how can I then manage the output? I need to publish product 1 and product 2 ... product 'x' separately.

Thank you for the assistance.

UPD: Here is the demo project on GitHub: https://github.com/plywoods/JekyllDocumentationDemo

like image 993
Andrey Langovoy Avatar asked Jan 19 '18 10:01

Andrey Langovoy


1 Answers

The way to have this content separation in Jekyll is through the use of Collections.

Here is an example of a Jekyll website using Collections: https://github.com/netponto/netponto.github.io

_meetings, _members, and _sessions are different collections and analogous to your _product1, _product2, etc.


You can customize the output / how the URL is going to be in the _config.yml of your Jekyll site. For example:

collections:
  meetings:
    output: true
    permalink: /reunioes/:path/
  sessions:
    output: true
    permalink: /sessoes/:path/

To display the items of a collection, for example the "sessions" collection, you do something like this:

{% for session in site.sessions %}
  <p>{{ session.title }}</p>
{% endfor %}

If you're having issues implementing the Collections, put together a reproducible example on GitHub, so that others can see what you've tried to do and point what's missing.

like image 195
C. Augusto Proiete Avatar answered Nov 17 '22 15:11

C. Augusto Proiete