.
Once that completes, import Ignite into your Swift code wherever needed:
```swift
import Ignite
```
## Create a layout to render Markdown files
Adding Markdown files to **Content** will render these to HTML pages and include them in **Build** with their respective folder structure, minus the **Content** part.
For example, adding a new file called `apps.md` to **Content** means having this folder structure:
```bash
├── Content
│ └── apps.md
```
And it results in this **Build** structure:
```bash
├── Build
│ ├── …
│ ├── apps
│ │ └── index.html
│ ├── …
```
**A precondition for this to work is to have a layout available to render your content.** If you don't have a valid layout in place, Ignite will issue a warning saying "Your site must provide at least one layout in order to render Markdown."
You can create custom layouts for articles by making types conform to the `ArticlePage` protocol, which will automatically be given an `article` property to access the content it is displaying. For example:
```swift
import Foundation
import Ignite
struct CustomArticleLayout: ArticlePage {
var body: some HTML {
Text(article.title)
.font(.title1)
if let image = article.image {
Image(image, description: article.imageDescription)
.resizable()
.cornerRadius(20)
.frame(maxHeight: 300)
}
if let tags = article.tags {
Section {
Text("Tagged with: \(tags.joined(separator: ", "))")
Text("\(article.estimatedWordCount) words; \(article.estimatedReadingMinutes) minutes to read.")
}
}
Text(article.text)
}
}
```
Once you've defined a custom layout, you should add it to your `Site` struct. This can be done by adding this new layout to the `articlePages` property of the site, like this:
```swift
struct ExampleSite: Site {
var name = "Hello World"
var url = URL(static: "https://www.example.com")
var homePage = Home()
var layout = MyLayout()
/* This part adds the custom layout */
var articlePages: [any ArticlePage] {
CustomArticleLayout()
}
}
```
The `Site` protocol provides sensible defaults for most properties, allowing you to focus on implementing only the customizations your site needs. As shown in the above, only a few properties like `name`, `url`, `homePage`, and `layout` require explicit implementation.
## Using the command-line tool
Once you have installed the Ignite command-line tool from this repository, you can use it in various ways.
First, you can create new site like this:
```shell
ignite new YourSite
```
When that completes, it will tell you the commands to use to open your new site for editing in Xcode:
```shell
cd YourSite
open Package.swift
```
> [!Tip]
> If you want to build with Xcode, go to the Product menu and choose Destination > My Mac.
Back in your terminal window, once you have run that `cd` command the current working directory of your terminal is your website's directory. This means you can run the following command to build your site, rather than using Xcode:
```shell
ignite build
```
That will convert all your Swift code to HTML in your **Build** folder.
You can also run this command:
```shell
ignite run --preview
```
That will launch a local web server you should use to preview your site, and also open it in your browser. If you're working in Xcode, you can continue performing builds as normal then refresh your browser to see your changes.
> [!Tip]
> The Ignite command-line tool has various configuration options available. Run `ignite help` to get general help, or add `help` before a subcommand to get further details, e.g. `ignite help run`.
## Websites made with Ignite
| Website | Repository |
|------------------------|-------------------------------------------|
| [Lighting Ignite on Fire](https://jptoro.dev/lighting-ignite-on-fire/) | [GitHub](https://github.com/JPToroDev/Lighting-Ignite-on-Fire) |
| [jcalderita Portfolio](https://jcalderita.com) | [GitHub](https://github.com/jcalderita/portfolio-web-ignite) |
| [Photo Club Hub](https://www.fcDeGender.nl/clubs) | [GitHub](https://github.com/vdhamer/Photo-Club-Hub-HTML) |
| [sookim-1's T.W.L](https://sookim-1.github.io) | [GitHub](https://github.com/sookim-1/blog-website) |
| [try! Swift Tokyo](https://tryswift.jp/en/) | [GitHub](https://github.com/tryswift/try-swift-tokyo) |
| [Tomo Codes](https://tomo.codes) | [GitHub](https://github.com/TomaszLizer/TomoCodes) |
| [Ryan Token](https://www.ryantoken.com) | [GitHub](https://github.com/r-token/ryantoken.com-v4-ignite) |
| [Codaglot](https://codaglot.skjorn.name) | [GitHub](https://github.com/skjorn/codaglot-showcase) |
## Contributing
I welcome all contributions, whether that's adding new tests, fixing up existing code, adding comments, or improving this README – everyone is welcome!
- You must comment your code thoroughly, using documentation comments or regular comments as applicable.
- Please ensure you run SwiftLint in the Sources directory, and fix all outstanding issues.
- All code must be licensed under the MIT license so it can benefit the most people.
- Ensure you build IgniteSamples using your modified copy of Ignite, and compare it to [the live version](https://github.com/twostraws/IgniteSamples).
- If you create a new element, please consider adding it to the IgniteSamples repository, so folks can see it more easily.
## Credits
Ignite is an open-source project with many contributors, including Paul Hudson, JP Toro, Henrik Christensen, Michael Freiwald, and Jobert Sá.
All contributions are welcome, but please ensure you abide by the [Code of Conduct](CODE_OF_CONDUCT.md).
## License
MIT License.
Copyright (c) 2024 Paul Hudson.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Ignite was originally created by [Paul Hudson](https://twitter.com/twostraws), who writes [free Swift tutorials over at Hacking with Swift](https://www.hackingwithswift.com). It’s available under the MIT license, which permits commercial use, modification, distribution, and private use.

A Hacking with Swift Project