Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
119 lines (79 sloc) 2.45 KB
description icon layout title weight
Getting started with a electric project.
arrow-right-rod
docs
Getting Started
1

Electric CLI

Install

npm i -g electric-cli

Initialize Project

electric init

This will prompt you for a project id and name, then it creates a folder in your current directory with your new electric project.

Run

electric run

This will build your newly created project and start up a development server along with a watch task for quickly making changes.

You can also modify the default port 8888 by running electric run -p 3000.

Project Structure

Here is a basic example of an electric project.

.
├── electric.config.js
└── src
    ├── layouts
    │   ├── base.soy
    │   └── docs.soy
    ├── pages
    │   ├── docs
    │   │   ├── create.md
    │   │   ├── index.soy
    │   │   └── parent
    │   │       ├── child.md
    │   │       └── index.md
    │   └── index.soy
    └── site.json

electric.config.js

This file provides configuration options to electric. It must always be located in the root directory of your project.

See configuration for more information.

site.json

This file contains meta data about your project. Any property can be added to this file. Front matter from all pages is merged with this data and passed to every page as a soy param.

Layouts

The file structure of layouts is flexible, as soy uses the namespace of every file as an identifier.

All layout files must be a soy template, and the only required layout is base.soy.

See layouts for more information.

Pages

Every file in pages with a .soy or .md extension is rendered to HTML during the build command.

The file structure of pages determines the urls of your pages. For the above example, the child.md file will be located at /docs/parent/child.html after building.

Pages named index will be located at the path of it's parent directory, so pages/docs/index.soy will be available at /docs/.

See pages for more information.