Creating Your Content

Creating a new page is easy:

  1. Open a new file in your text editor.
  2. Enter some content (in Markdown format).
  3. Save the file in the content/pages/ directory with a .mdown extension.

You just need to make sure that you save your file in the pages directory (the precise path is defined in config/config.yml).

Writing web pages

Here’s an example of the Markdown for a simple page:

# British Breakfasts

This is a page about breakfast.

Common choices for a tasty breakfast:

- *English:* Bacon (chunky), eggs (fried), beans...
- *Scottish:* Lorne sausage, potato scones, haggis...

## English breakfasts

The traditional English breakfast (or "fry up")...

Let’s break this example down a bit:

  • Every web page should have a main heading. In Markdown you can create the heading tag by starting the line with a # character (equivalent to an h1 tag in HTML).
  • The heading is followed by two paragraphs and a bulleted list.
  • Finally there’s a second level heading (equivalent to an h2 tag) and another paragraph.

See the markdown cheat sheet for a more in depth look at how you can format your text.

Choosing a URL

The page’s URL will be created from the name of the file; if you save the page to a file called apple-pie.mdown inside the content/pages/pudding/ directory, it will be served from http://your.site/pudding/apple-pie.

If your page needs more than one word in the URL we recommend that you separate those words with hyphens. Some people prefer underscores, but hyphens have two clear advantages:

  1. Underscores can be confused with spaces when viewed in underlined hyperlinks.
  2. Underscores may lose some of the SEO benefit of user friendly URLs; search engines often see a hyphen as a word separator and an underscore as part of the word. We can be fairly sure that there’s not a lot of demand online for “apple_pie”, so just don’t do it!

Writing articles and blog posts

There’s really nothing special about a blog post. They’re just web pages that are published on a certain date. They might also be written on a similar topic to other articles on our blog.

Imagine for a moment that we’re writing a blog post for a site in which we often discuss food and travel. We can easily convert our web page into a blog post:

Date: 6 October 2009
Categories: food, travel

# Breakfast in Europe

This is a page about breakfast.

...

The top two lines don’t appear on the page directly, but they tell Nesta how you’d like it to treat your page.

The Date: line is pretty straightforward; it defines the date that your post was published. The date is displayed on the page. It is also used when identifying the latest articles that should appear on your site’s home page, and choosing articles to include in your site’s Atom feed.

Categories: refers to other pages that collate information on topics related to this post. In the example above we’re referring to pages stored in content/pages/food.mdown and content/pages/travel.mdown. A link to this post will automatically be included at the bottom of both of those pages. Category pages are a great way to structure a web site.

See the metadata reference for more details on Date and Categories, or to find out what else you can do with Nesta’s metadata fields. When writing posts of more than a paragraph or two in length you should definitely check out the Read more and Summary options.

Adding attachments

Attachments are stored in the attachments sub directory of your content directory. You can then refer to them in your web pages via URLs beginning with /attachments:

Examples:

Download my [superb eBook](/attachments/my-ebook.pdf).

Here's a great picture:

<img src="/attachments/my-image.png" alt="Great picture"/>

You’ll no doubt have noticed that this example includes an image with an HTML tag. That’s the nice thing about Markdown; if it doesn’t support what you need you can drop into HTML to say what you really mean. I find that it’s rarely necessary, but it’s nice to be able to fall back on HTML if the need arises.

Of course, there’s nothing to stop you from putting your images into Nesta’s public directory (any file that you drop into public will be served automatically). The only reason that the content/attachments directory exists is that it allows you to keep your text and images together inside the content folder.