Visitar URL original
Virtual Templates don't work as expected with layouts configured outside of the input root · Issue #4409 · 11ty/buildawesome · GitHub
Skip to content

Virtual Templates don't work as expected with layouts configured outside of the input root #4409

Open

Description

@andrewhayward

Operating system

macOS Golden Gate 27.0.1

Eleventy

3.1.7

Describe the bug

With a traditional dir config, virtual template layouts work fine:

/
├─ site/
│  ├─ _includes/
│  │  └─ ...
│  ├─ _layouts/
│  │  └─ disk.html
│  ├─ disk.md
│  └─ virtual.md
└─ .eleventy.js
// .eleventy.js

export default function (eleventyConfig) {
  eleventyConfig.addTemplate('_layouts/virtual.html', '...');

  return {
    dir: {
      input: 'site',
      includes: '_includes',
      layouts: '_layouts',
    }
  }
}

Both disk.md and virtual.md compile as expected.

// ✅ site/disk.md

---
layout: disk.html
---
...
// ✅ site/virtual.md

---
layout: virtual.html
---
...

However, while moving includes and layouts outside of the input directory works fine from disk, it doesn't work for virtual templates:

/
├─ site/
│  ├─ disk.md
│  └─ virtual.md
├─ includes/
│  └─ ...
├─ layouts/
│  └─ disk.html
└─ .eleventy.js
// .eleventy.js

export default function (eleventyConfig) {
  eleventyConfig.addTemplate('../layouts/virtual.html', '...');

  return {
    dir: {
      input: 'site',
      includes: '../includes',
      layouts: '../layouts',
    }
  }
}

disk.md compiles correctly, using the disk.html layout found outside the site root, but virtual.md complains that the virtual.html layout does not exist.

// ✅ site/disk.md

---
layout: disk.html
---
...
// ❌ site/virtual.md

---
layout: virtual.html
---
...

I'm guessing that the virtual file system is not parsing template paths "correctly", but I haven't had a chance to look properly.

Reproduction Source Code URL

No response

Screenshots

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions