Skip to content
NaturaLife Astro Theme

Content and Collections

Create blog posts, products, portfolio projects and text pages, then manage their relationships, archive views and draft status.

Create src/content/blog/authors/editor.json:

{ "id": "editor", "name": "Your editor", "bio": "About your editor." }

Create src/content/blog/categories/garden.json:

{ "id": "garden", "slug": "garden", "name": "Garden" }

Add your own image at src/assets/garden.jpg, then create src/content/blog/posts/garden-notes.mdx:

---
id: garden-notes
slug: garden-notes
title: Garden notes
description: Notes from our garden.
publishDate: "2026-10-29"
author: editor
categories: [garden]
coverImage: ../../../assets/garden.jpg
coverImageAlt: Our garden in autumn
draft: false
---
import ContentImage from '@rtthemes/naturalife/components/ContentImage.astro';
import photo from '../../../assets/garden.jpg';
## A fresh start
Write your article here.
<ContentImage src={photo} alt="Our garden in autumn" />

This exact folder depth needs three ../ segments for the image. A deeper folder needs another segment. Run npm run check and npm run build, then preview /blog/garden-notes/. The post also appears in the generated blog, category and author archives.

Keep id stable. Relationships use IDs, not display names or filenames; slug controls the normal public URL. Blog tags are JSON records under src/content/blog/tags/ and are selected through the post’s tags IDs. Categories can use parent with another category ID in the same content type. Changing a parent does not change the category URL.

Missing references, duplicate identities, category cycles and URL collisions fail validation. Draft records also need valid references. When changing a published slug, arrange a redirect from the old URL.

Add your image at src/assets/garden-set.jpg. Create src/content/products/items/garden-set.mdx:

---
id: garden-set
slug: garden-set
title: Garden set
description: A demonstration garden set.
coverImage: ../../../assets/garden-set.jpg
coverImageAlt: Garden tool set
priceLabel: "$20.00"
priceCents: 2000
currency: USD
categories: []
tags: []
---
Write the product description here.

It appears at /products/garden-set/. Product categories and tags have their own JSON folders under src/content/products/. Optional related contains product IDs. priceCents is a nonnegative integer used by the local demo cart; priceLabel is display text. These fields do not connect a payment service.

For a project, create src/content/portfolio/items/garden-project.mdx with the same identity, title, description and cover fields, and omit the price/currency/tags fields. Use optional categories, related, images and project label/value facts as needed. It appears at /portfolio/garden-project/; category JSON belongs under src/content/portfolio/categories/. There is no portfolio tag collection.

Ordinary records need no presentation object. Supplied complex gallery, video, split, sticky or tabbed variants retain structured presentation settings; their dedicated panels are not replaced by arbitrary MDX body text.

Create src/content/documents/our-story.mdx:

---
id: our-story
slug: our-story
title: Our story
description: How we started.
---
## Our beginning
Write your story here.

The customer catch-all route generates /our-story/. Optional width: wide, breadcrumbs: false, lang and seo adjust the document layout. Do not choose a URL already owned by another route. Designed pages continue to use JSON plus Astro composition.

One record supplies its detail and collection views. Generated archives use six records per page, with real /page/2/ links. Change the page size in src/lib/pagination.ts.

draft: true removes a record from generated detail routes, published queries, selected cards and sitemap output. Your explicitly authored navigation and campaign links still need maintenance. Curated sections do not automatically include every new record.