Nsokyi
Nsokyi

Reputation: 394

Is it possible to have nested collections in Jekyll?

I am trying to create a one-page portfolio theme in Jekyll, one section has the default Jekyll blog posts, and another has collections.

I would like the collections section to be the portfolio section. In that I'd like to keep everything on the one page and not the typical click on an image and go to a post url. Rather I’d like to have - click on an image and have a full screen image slider pop up. I also need the portfolio section to be filtered in to categories - such as Web Design - Graphics - Photography and so on.

So is it possible to have nested collections in Jekyll? With each collection having it's own sub collection/category so Web Design would have say four projects and each project has four or five slides?

my config.yml

  collections:
    webdesign: webdesign-project-one
    webdesign: webdesign-project-two
    webdesign: webdesign-project-three
    webdesign: webdesign-project-four
    graphics: graphic-project-one
    graphics: graphic-project-two
    graphics: graphic-project-three
    graphics: graphic-project-four  
    photos: photo-project-four 
    photos: photo-project-four 
    photos: photo-project-four 

code to display

        <div id="slide-item01" class="portfolio webDesign">
          <div class="slides">
            {% for work in site.webdesign | where: "webdesign-project-one" %}
            <div class="slide-cell">
            <div class="wrap">
              <img src="{{ work.thumbnail-path }}" alt="{{ work.title }}"/>
                <div>
                  <h2>{{ work.title }}</h2>
                  {{ work.content }}
                </div>
              </div>
            </div>
            {% endfor %}
          </div>
        </div>

post markdown

    ---
    thumbnail-path: assets/img/webdesign/webdesign-project-one_slide-one.jpg
    title: Web Design Project One Slide One
    ---

    content

Structure

    portfolio/
    _incliudes/
    --work.html

    _layouts/
    --frontpage.html

    _webdesign/
    --webdesign-project-one/
    ---slide-one.md
    ---slide-two.md
    ---slide-three.md
    ---slide-four.md
    --webdesign-project-two/
    ---slide-one.md
    ---slide-two.md
    ---slide-three.md
    --webdesign-project-three/
    ---slide-one.md
    ---slide-two.md
    --webdesign-project-four/
    ---slide-one.md
    ---slide-two.md
    ---slide-three.md

    _graphics/
    --graphic-project-one/
    ---slide-one.md
    ---slide-two.md
    ---slide-three.md
    ---slide-four.md
    --graphic-project-two/
    ---slide-one.md
    ---slide-two.md
    ---slide-three.md

Upvotes: 3

Views: 2216

Answers (1)

Mr. Hugo
Mr. Hugo

Reputation: 12582

Nested collections are not possible, as 'collections have to be in the source directory'. You can use front matter and filtering as a work-around. See: https://github.com/jekyll/jekyll/issues/2386

Upvotes: 2

Related Questions