Working with content

Ignite parses Markdown files in in your Content folder, automatically converting them to pages.

You should create subfolders inside Content to represent different types of articles. This might be by date, e.g. Content/2023, Content/2024, etc, by type, e.g. Content/posts, Content/tutorials, or whatever other approach you want.

When it come to rendering your articles, you have two options:

  1. You can use YAML front matter to specify the layout to use for your article.
  2. You can provide only one layout in your site, and it will be used if nothing else is specified.

This example site contains two types of articles, posts and stories. Some articles requests a specific layout, but others don’t.

This article uses the default layout.

And this article uses a custom layout.

Listing articles

You can access Markdown content by adding the property @Environment(\.articles) var articles to your view, which lets you read all articles, or articles with a specific type or tag.

For example, we can write code to show a list of all articles right here on this page:

List {
    ForEach(articles.all) { article in
        Link(article)
    }
}

Or we could show only articles that matches the type story:

List {
    ForEach(articles.typed("story")) { article in
        Link(article)
    }
}

But there are a handful of helpers available to make things both easier and more attractive.

First, ArticlePreview can be used to make a preview for articles. This automatically includes the articles image, title, description, link, and tags, all in one:

Grid(articles.all, alignment: .top) { item in
    ArticlePreview(for: item)
        .width(3)
        .margin(.bottom)
}

So you think you know Swift? Think again! Fresh from the success of our audiobook launch, Laboratoires TwoStraws is back with an all-new card game that will finally give you something to do while waiting for Xcode to finish indexing.

Although Swift gives us powerful programming technologies such as generics, protocols, and type inference, if there’s one thing we can all agree has been sorely lacking it’s built-in support for scalable concurrent transactions using RESTful middleware and messaging.

In the heart of Cupertino, amidst the buzz of WWDC, a caper of canine proportions was about to unfold, starring two unwitting heroines: Luna and Arya, the fluffy Samoyeds who are the real power behind Hacking with Swift. Little did anyone know, these two bundles of fur were about to turn Apple Park into their personal playground, all under the watchful eyes of tech enthusiasts and Apple executives alike.

Once upon a time in a land not so far away, nestled between the rolling hills of Silicon Valley, there was a developer named Sam Swift. Sam, as his name might suggest, was not just any developer; he was a Swift developer. A coder of high esteem, known across the land for his quick wit and even quicker compile times.

YAML front matter

Ignite supports Jekyll-style YAML front matter to specify metadata.

Specifically, the following fields are supported:

As well as the predefined fields, you can use the metadata dictionary to access any custom properties you have defined in the front matter. Note that the dictionary values are optionals: your page code must be able to deal with the dictionary item not existing!

Text(article.metadata["CustomValue"] ?? "Not defined")

In addition, you can read properties such as estimatedWordCount and estimatedReadingMinutes on your content, to provide extra information to users.

Tag pages

If you make a type that conforms to the TagPage protocol, you can use it to display tag pages on your site.

This protocol passes you one of two types conforming to the Category protocol: TagCategory, which represents a page dedicated the content of a single tag, or AllTagsCategory, which represents a page featuring all tags and their content.

This sample site has a small tags page implementation. You can see it in action with these links:

Created in Swift with Ignite

Ignite v0.5.2 · Updated 22/04/25