Skip to content

Structuring posts in _posts/year/posts-title.md #756

@tomasnorre

Description

@tomasnorre

I use the Jigsaw for my blog, and I would like to group my posts a little more, so that my posts directory would look a little like

├── 2021
│   └── no-tracking-no-cookies.md
├── 2022
│   └── any-docker-images-to-be-updated.md
├── 2023
│   └── reading-productivity.md
├── 2024
│   ├── freelancer.md
│   └── kamal-deploy.md
├── 2025
│   └── black-friday.md

instead of

├── no-tracking-no-cookies.md
├── any-docker-images-to-be-updated.md
├── reading-productivity.md
├── freelancer.md
├── kamal-deploy.md
├── black-friday.md

Which could blow up quite easily with many posts.

In the URLs I can group them but adding a path in my config.php {date|Y}

'collections' => [
  'posts' => [
    'path' => 'blog/{date|Y}/{filename}',
  ],
]

But the second I do that my Vite Build crashes, as it cannot find the posts anymore for the RSS.

<entry>
    <id>{{ $entry->getUrl() }}</id>
    <link type="text/html" rel="alternate" href="{{ $entry->getUrl() }}" />
    <title>{{ $entry->title }}</title>
    <published>{{ date(DATE_ATOM, $entry->date) }}</published>
    <updated>{{ date(DATE_ATOM, $entry->date) }}</updated>
    <author>
        <name>{{ $entry->author }}</name>
    </author>
    <summary type="html">{{ $entry->getExcerpt() }}...</summary>
    <content type="html"><![CDATA[
        @includeFirst(['_posts.' . $entry->getFilename(), '_posts._tmp.' . $entry->getFilename()])
    ]]></content>
</entry>

The line @includeFirst(['_posts.' . $entry->getFilename(), '_posts._tmp.' . $entry->getFilename()]) gives problems as the view isn't found any more.

I have tried to adjust them with $entry->date()->format('Y') but without any luck.

I haven't found the place where to correct this properly yet, but I think it's should be allowed within Jigsaw to group posts in folders too.

Infos:

tightenco/jigsaw: 1.8.3

Update:

If I update the file with the line giving me problems, it works. But only if I add all posts to a year folder. It's not a problem, but I would have expected that the other rules would still catch it, if not.

<content type="html"><![CDATA[
    @includeFirst([
        '_posts.' . $entry->getDate()->format('Y') . '.'. $entry->getFilename(),
        '_posts.' . $entry->getFilename(),
        '_posts._tmp.' . $entry->getFilename()
        ])
]]></content>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions