Overview

In the previous section we setup our local development environment and installed Greenwood. We also made a "workspace" for our project files in a directory called src/.

Although Greenwood works without any configuration or setup, (go ahead, run npm run build, you'll get a default site right out of the box!), you will of course want to create your own site with your own content.

For this reason, the minimum requirements for a site that you will want to be familiar with are:

  1. Workspace
  2. Template(s)
  3. Page(s)

In this section, we hope you'll get a better understanding of key concepts and how they can be used to create as many layouts and pages as you need to build out your own site however you need.

Workspace

In the project setup section, we created a src/ directory at the root of the directory of the project. To Greenwood, this is called your workspace and where are the files for your project need to reside, including the next two key concepts: templates and pages.

This gives our project the following structure:

.
├── package-lock.json
├── package.json
└── src/

Aside from these templates and pages directories, you can use any name you want for your other directories since your templates will be able to use JavaScript module with import to pull in anything you need. This will be demonstrated more fully in the next section.

Templates

Templates are used to define the various layouts you will need for your site and should be put into a templates/ directory in your workspace directory. You will need to define at least one page template for your project in order to get control over the output of your site, called page-tempate.js.

So using the project structure we setup previously, adding your own custom page layout would leave you with a directory layout like this:

.
├── package-lock.json
├── package.json
└── src
    └── templates
        └── page-template.js

For reference, here's what the default page template included by Greenwood looks like (using LitElement).

import { html, LitElement } from 'lit-element';
MDIMPORT;

class PageTemplate extends LitElement {
  render() {
    return html`
      <div class='gwd-wrapper'>
        <div class='gwd-page-template gwd-content'>
          <entry></entry>
        </div>
      </div>
    `;
  }
}

customElements.define('page-template', PageTemplate);

Don't worry too much about the capitalized expression, this is discussed in more detail in our docs. Also, as seen here, Greenwood provides a version of LitElement by default that you can use for your own components if you would like.

Pages

Pages are how you will create the content for your site by (generally) creating markdown files. Simply make a pages/ directory in your workspace and Greenwood will start building them automatically. By default, pages will build using the default page template: page-template.js.

By adding a home page (index.md), your directory structure for a basic Greenwood application would now look like this:

.
├── package-lock.json
├── package.json
└── src
    ├── pages
    │   └── index.md
    └── templates
        └── page-template.js

And the sample home page provided by Greenwood out of the box looks like this:

### Greenwood

This is the home page built by Greenwood. Make your own pages in src/pages/index.js!

Ok, so with the key concepts of workspaces, templates and pages covered, you're now ready to start creating content and developing your first Greenwood site!