Skip to content
This repository was archived by the owner on Oct 16, 2021. It is now read-only.
This repository was archived by the owner on Oct 16, 2021. It is now read-only.

Question: Year / Month / Post Pathing #129

Description

@thnk2wn

I'm new to Eleventy and trying Hylia for the first time. I am wondering how to best do relative image links with image subdirectories per post?

I have imported from Wordpress similar to this post.

I have the following structure with blog posts organized by year/month/post and images in a subfolder of each post.

image-structure

I copied the images over with this in eleventy.js:

// for now - this is mostly to keep images nested with their posts
config.addPassthroughCopy('src/posts/**/images/*');

The post collections in the same file:

  // Custom collections
  const livePosts = post => post.date <= now && !post.data.draft;
  config.addCollection('posts', collection => {
    return [
      ...collection.getFilteredByGlob('./src/posts/**/*.md').filter(livePosts)
    ].reverse();
  });

  config.addCollection('postFeed', collection => {
    return [...collection.getFilteredByGlob('./src/posts/**/*.md').filter(livePosts)]
      .reverse()
      .slice(0, site.maxPostsPerPage);
  });

The markdown posts have relative image links like:

![Open PowerShell here](images/OpenPowerShellHere.png)

When running the generation I see errors like:

`TemplateWriterWriteError` was thrown
> ENOENT: no such file or directory,
open '/Users/hudgeo/Projects/blog/03-hylia/srcimages/OpenPowerShellHere.png'

Related issue with posts being in their own folder and url expecting prefixed file:

image

My repo is here

I'm just trying to figure out what configuration or layout changes to make for this structure or whether its easier to go with a different structure?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions