Skip to content

Comments

Separate notes collection with proper /notes/ permalinks and documentation#108

Open
Copilot wants to merge 5 commits intomainfrom
copilot/update-slug-for-notes
Open

Separate notes collection with proper /notes/ permalinks and documentation#108
Copilot wants to merge 5 commits intomainfrom
copilot/update-slug-for-notes

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Description

Notes were tagged correctly but stored in src/posts/, causing them to generate /posts/{slug}/ URLs. Site infrastructure (feeds, home layout) already expected a separate notes collection. This PR implements the proper collection structure and adds comprehensive documentation for managing content.

Related Issue

Changes Made

  • Created src/notes/ directory and moved 6 note files from src/posts/
  • Added directory data files to set collection tags and permalink patterns:
    • src/posts/posts.json: permalink: "/posts/{{ page.fileSlug }}/"
    • src/notes/notes.json: permalink: "/notes/{{ page.fileSlug }}/"
  • Created comprehensive publishing guide at docs/how-to/publishing-content.md with:
    • Step-by-step instructions for publishing posts and notes
    • Front matter reference and examples
    • Best practices for file naming and organization
    • Troubleshooting common issues
  • Updated AGENTS.md with:
    • Link to publishing guide
    • Content management quick reference section
    • Updated project structure documentation

Result: Notes now generate /notes/{slug}/ URLs, posts generate /posts/{slug}/ URLs (cleaner, date-prefix removed)

// src/notes/notes.json
{
  "tags": "notes",
  "permalink": "/notes/{{ page.fileSlug }}/"
}

Checklist

  • Code follows engineering principles (simplicity, smallest possible change)
  • Site builds successfully (npm run build:prod)
  • Changes tested locally (npm start)
  • Documentation updated (if needed)
  • No unnecessary dependencies added
  • Changes are minimal and focused

Screenshots (if applicable)

N/A - Content reorganization and documentation, no visual changes to rendered pages

Original prompt

This section details on the original issue you should resolve

<issue_title>update slug for “notes”</issue_title>
<issue_description>### Runbook: Implementing Collections for "Posts" and "Notes" in Eleventy (11ty)

Goal:

  1. Organize content into posts and notes collections.
  2. Set default permalinks for each collection.
  3. Ensure both collections reside in a collections/ directory.

1. Directory Structure

Ensure your project has the following directory structure:

.
├── collections/
│   ├── posts/
│   │   ├── example-post.md
│   ├── notes/
│       ├── example-note.md
└── .eleventy.js

2. Content Example

Example Post (collections/posts/example-post.md):

---
title: "Example Post"
date: 2026-02-03
layout: post.njk
---
This is an example post content.

Example Note (collections/notes/example-note.md):

---
title: "Quick Note"
date: 2026-02-03
layout: note.njk
---
This is an example note content.

3. Modify .eleventy.js

Update your Eleventy configuration to define collections and default permalinks.

module.exports = function(eleventyConfig) {
  // Add collections for posts and notes
  eleventyConfig.addCollection("posts", function(collectionApi) {
    return collectionApi.getFilteredByGlob("./collections/posts/*.md");
  });

  eleventyConfig.addCollection("notes", function(collectionApi) {
    return collectionApi.getFilteredByGlob("./collections/notes/*.md");
  });

  // Set default global permalinks
  return {
    dir: {
      input: ".",
      output: "_site"
    },
    // Set permalinks dynamically for posts and notes
    eleventyComputed: {
      permalink: function(data) {
        if (data.page.inputPath.includes("collections/posts")) {
          return `/posts/${data.page.fileSlug}/`;
        }
        if (data.page.inputPath.includes("collections/notes")) {
          return `/notes/${data.page.fileSlug}/`;
        }
        return data.page.filePathStem + "/";
      }
    }
  };
};

4. Verify Layouts

Ensure the layouts for posts and notes are defined in the layouts/ folder (e.g., layouts/post.njk and layouts/note.njk).

Layout for Posts (example: layouts/post.njk):

<!DOCTYPE html>
<html lang="en">
<head>
  <title>{{ title }}</title>
</head>
<body>
  <article>
    <h1>{{ title }}</h1>
    <p>{{ content | safe }}</p>
  </article>
</body>
</html>

Layout for Notes (example: layouts/note.njk):

<!DOCTYPE html>
<html lang="en">
<head>
  <title>{{ title }}</title>
</head>
<body>
  <aside>
    <h1>{{ title }}</h1>
    <p>{{ content | safe }}</p>
  </aside>
</body>
</html>

5. Test Locally

  1. Run locally to confirm changes work as expected:

    npm start
  2. Verify the URLs for posts (/posts/example-post/) and notes (/notes/example-note/).


6. Deployment

  1. Commit changes:

    git add .
    git commit -m "Set up posts and notes collections with custom permalinks"
    git push origin main
  2. Deploy your site to the desired environment (manual or CI-based deployment).


7. Optional Enhancements

  • Index Pages:

    • Create /posts/ and /notes/ index pages to list all content in each collection.
  • Styling:

    • Customize the styles for posts and notes in src/css/ and ensure they are part of your build process.
  • SEO:

    • Add meta information for better search engine optimization.
      </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ermalinks

Co-authored-by: benkutil <228373+benkutil@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 3, 2026

Deploying benkutil-github-io with  Cloudflare Pages  Cloudflare Pages

Latest commit: b419e89
Status: ✅  Deploy successful!
Preview URL: https://4ab93f4b.benkutil-github-io.pages.dev
Branch Preview URL: https://copilot-update-slug-for-note.benkutil-github-io.pages.dev

View logs

Copilot AI changed the title [WIP] Update slug for notes collection Separate notes collection with proper /notes/ permalinks Feb 3, 2026
Copilot AI requested a review from benkutil February 3, 2026 03:05
@benkutil
Copy link
Owner

benkutil commented Feb 3, 2026

@copilot two updates:

  1. Can you create a "how to" guide for publishing that lives at "docs/how-to" about publishing these types of content.
  2. Update the Agents.md file with details for an agent

Co-authored-by: benkutil <228373+benkutil@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot two updates:

  1. Can you create a "how to" guide for publishing that lives at "docs/how-to" about publishing these types of content. ...

Done! I've created both:

  1. Publishing Guide: docs/how-to/publishing-content.md - Comprehensive guide with step-by-step instructions for creating posts and notes, including front matter examples, best practices, and troubleshooting.

  2. Content Collections Agent: .github/agents/content-collections-agent.md - Specialized agent documentation for managing the posts and notes collections, directory structure, and permalinks.

I've also updated AGENTS.md to reference both the new agent and the publishing guide with a quick reference section for content management.

Commit: 9c44523

Copilot AI changed the title Separate notes collection with proper /notes/ permalinks Separate notes collection with proper /notes/ permalinks and documentation Feb 3, 2026
AGENTS.md Outdated
The project includes specialized agents for specific tasks:

- **Writing Agent** (`.github/agents/writing-agent.md`) - Content creation and editing following the site's writing style
- **Content Collections Agent** (`.github/agents/content-collections-agent.md`) - Managing posts and notes collections, directory structure, and permalinks
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the Content Collections Agent reference from AGENTS.md.

Commit: b419e89

Co-authored-by: benkutil <228373+benkutil@users.noreply.github.com>
Copilot AI requested a review from benkutil February 3, 2026 03:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Separates “notes” into their own Eleventy collection so they publish under /notes/…/ instead of /posts/…/, and adds contributor documentation for publishing content.

Changes:

  • Added directory data files to define posts and notes collections and their permalink patterns.
  • Introduced src/notes/ and added/moved note content into it.
  • Added a detailed publishing guide and updated contributor/agent documentation.

Reviewed changes

Copilot reviewed 4 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/posts/posts.json Defines default posts tag + /posts/{{ … }}/ permalink pattern for files in src/posts/.
src/notes/notes.json Defines default notes tag + /notes/{{ … }}/ permalink pattern for files in src/notes/.
src/notes/2023-01-04-context.md Adds note content under the new notes collection.
src/notes/2022-12-22-the-stretch-pants-of-work.md Adds note content under the new notes collection.
src/notes/2022-12-18-order-of-operations.md Adds note content under the new notes collection.
src/notes/2022-12-15-debugging-is-hard.md Adds note content under the new notes collection.
src/notes/2022-12-14-christmas-lists-are-boring.md Adds note content under the new notes collection.
src/notes/2022-12-13-gov-org-chart.md Adds note content under the new notes collection.
docs/how-to/publishing-content.md Documents how to publish posts/notes, including permalink conventions and examples.
AGENTS.md Updates project structure + adds content management quick reference and agent links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- **Notes**: Short thoughts in `src/notes/`, URL pattern `/notes/{slug}/`
- Both use directory data files (`posts.json`, `notes.json`) for default configuration
- Filenames use date prefix: `YYYY-MM-DD-title.md`
- Permalinks are clean, without date prefixes
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This quick reference says permalinks are “clean, without date prefixes”, but the current collection permalinks use {{ page.fileSlug }}, which will include the YYYY-MM-DD- prefix when filenames follow the documented convention. Align this statement with the actual permalink behavior (or update permalink generation to strip the date prefix).

Suggested change
- Permalinks are clean, without date prefixes
- Permalinks include the date prefix from the filename (e.g. `/posts/2024-01-01-title/`)

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +95
- **Writing Agent** (`.github/agents/writing-agent.md`) - Content creation and editing following the site's writing style

When working on tasks related to these domains, consult the appropriate agent documentation.
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AGENTS.md references .github/agents/content-collections-agent.md, but that file does not exist in the repo (only .github/agents/writing-agent.md is present). Either add the missing agent doc or remove/update this reference to avoid a broken link.

Copilot uses AI. Check for mistakes.
Comment on lines +140 to +144
The `{slug}` is derived from your filename, removing the date prefix:

- File: `2026-02-03-my-new-post.md`
- URL: `/posts/my-new-post/`

Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section says {slug} is derived by removing the date prefix (e.g., 2026-02-03-my-new-post.md/posts/my-new-post/), but the configured permalinks use {{ page.fileSlug }}, which will include the full filename (including the date prefix). Update the documentation examples (including earlier localhost URLs) or change permalink/slug generation so URLs actually drop the date prefix.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,4 @@
{
"tags": "posts",
"permalink": "/posts/{{ page.fileSlug }}/"
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page.fileSlug includes the full filename (e.g., 2026-02-03-my-new-post), so this permalink will keep the date prefix in the URL. This contradicts the PR goal/docs of “clean” slugs without date prefixes. Consider using a computed slug that strips the leading YYYY-MM-DD- (or update the docs/file-naming guidance to match the actual URL behavior).

Suggested change
"permalink": "/posts/{{ page.fileSlug }}/"
"permalink": "/posts/{{ page.fileSlug | split('-') | slice(3) | join('-') }}/"

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,4 @@
{
"tags": "notes",
"permalink": "/notes/{{ page.fileSlug }}/"
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page.fileSlug preserves the date prefix from filenames like 2022-12-14-..., so this will generate /notes/2022-12-14-.../ rather than the documented /notes/{slug}/ without the date. If the intended behavior is to drop the date prefix, update the permalink to use a computed slug that strips it.

Suggested change
"permalink": "/notes/{{ page.fileSlug }}/"
"permalink": "/notes/{{ page.fileSlug | slice(11) }}/"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update slug for “notes”

2 participants