Skip to content

Issues implementing layout to blog posts. #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Albertyhu opened this issue Jul 13, 2023 · 1 comment
Open

Issues implementing layout to blog posts. #73

Albertyhu opened this issue Jul 13, 2023 · 1 comment

Comments

@Albertyhu
Copy link

Albertyhu commented Jul 13, 2023

I am currently learning how to use astro-netlify-cms to create a sample blogging and I am having trouble implementing the layout for the blogs.

My folder structure looks like the following

-src
-layouts
-MarkdownPostLayout.astro
-pages
-posts
-blog1.md
astro.config.mjs

Here is my astro.config.mjs file:
https://github.com/Albertyhu/astro-blog-with-netlify-cms/blob/main/astro.config.mjs

In collections, I set the field layout to the following:

{
          name: "layout",
          widget: "hidden",
          label: "Layout",
          default: `import layout from '../../layouts/MarkdownPostLayout.astro'`,
        },

Here is the Github repository for the rest of the project: https://github.com/Albertyhu/astro-blog-with-netlify-cms/tree/main

I appreciate any help I can get here.

@fkkehlet
Copy link

I see you are missing a content/ folder - astro will not recognize your .md files outside of content/ I don't think, so you need to move posts/ to content/posts/, define a content collection, and then create a [post].astro in your pages folder to render the page. See the docs below:

https://docs.astro.build/en/guides/content-collections/

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

No branches or pull requests

2 participants