Regarding generation of multiple files from a single content template #1824
-
Hello. I'm using Eleventy for the first time to build a new version of my website for my art practice. It's essentially a portfolio website of my artwork. I'm using Nunjucks templating. I'm also using Forestry.io as a CMS, though I also hand-code much of the work. (1) Each artwork has an individual template in the
(2) In my previous framework-based website, I used the following url scheme (via routing) to arrange artworks into "portfolios". Artworks could appear in one or more portfolios. Each artwork also had a page which was not bound to any particular portfolio:
I'm making use of Eleventy's tags (auto-collections) capability to create what are essentially portfolios. I would like to keep the established url structure I had with my previous framework-based website. Using the following pagination template I get the following generated file tree. Note that this pagination template also uses the same
The generated pages are essentially fine. But I have the following questions: (3)
Question: Is there some way to make the first map to (4)
For those still with me 😱😅 : the reason I'm trying to do this is to maintain the portfolio context when viewing an artwork. For instance, when the portfolio context is abstract, the previous and next buttons on the page should go to the next artwork in Thanks very much for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think there might be 2 solutions:
<title>{{ title | default: artwork.data.title }}</title> This should use
---
# ./works-abstract.md
layout: layouts/works/artwork
tag: abstract
pagination:
data: collections.abstract
size: 1
alias: artwork
permalink: "/works/{{ artwork.fileSlug | slug }}/{{ tag | slug }}/"
eleventyComputed:
title: "{{ artwork.data.title }}"
--- I think this is probably my preferred solution, but should set the current paginated item's In _site/works/artwork-001/index.html
# artwork content in the .md file is accessed using {{content}}
In _site/works/artwork-001/abstract/index.html
# {{artwork.data.content}} returns the markup for the entire template! Why is that? That's just how pagination works usually (needing to access via <main>
<article>{{ content | strip }}</article>
</main> |
Beta Was this translation helpful? Give feedback.
I think there might be 2 solutions:
default
filter (assuming you're using the default engine for .md files and didn't replace it w/ Nunjucks; in which case you'd have to write your owndefault
filter):This should use
title
if available, and fall back toartwork.data.title
iftitle
was falsy.eleventyComputed
in your paginated pages to set local variables.