# stratify-web

> A simple tool to build out a static website using nothing but Markdown.

Latest version **1.3.1** (published 2022-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install stratify-web
pnpm add stratify-web
yarn add stratify-web
bun add stratify-web
```

Provides the commands `stratify`, `create-stratify-project`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2022-05-25 |
| First published | 2022-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 19.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | d_e_v.e_s_h |

## Links

- npm: https://www.npmjs.com/package/stratify-web
- npm.io page: https://npm.io/package/stratify-web

## Dependencies (5)

- [dotenv](https://npm.io/package/dotenv.md) ^16.0.1
- [marked](https://npm.io/package/marked.md) ^4.0.12
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [live-server](https://npm.io/package/live-server.md) ^1.1.0
- [html-minifier](https://npm.io/package/html-minifier.md) ^4.0.0

## Recent versions

- 1.3.1 (latest) — 2022-05-25
- 1.3.0 — 2022-05-12
- 1.2.3 — 2022-03-21
- 1.2.2 — 2022-03-21
- 1.2.1 — 2022-03-20
- 1.2.0 — 2022-03-20
- 1.1.0 — 2022-02-07
- 1.0.0 — 2022-02-06

## README

# Stratify

<p align="center">
    <img src="https://firebasestorage.googleapis.com/v0/b/devesh-blog-3fbfc.appspot.com/o/postimages%2Fbuilding-a-static-site-generator%2Fprimaryimage.jpg?alt=media&token=af97b450-71ec-4380-a931-dd17b4c5374b" />
</p>

A simple tool to build out a static website using nothing but Markdown. Useful for static blog sites and feeds.

### Read the writeup

You can read a documented process of building this tool [here](https://blog.devesh.tech/post/building-a-static-site-generator).

### Get Started

```
npm i -g stratify-web
```

### Min Requirements

NodeJS > `14.0.0`

### Create a New Project

```bash
create-stratify-project <Directory Path> <App Name>
cd <Directory Path>
```

This creates a simple project at the directory path.

### Editing Your Pages

Use the `pages` folder to make changes to your pages. They support comments, all markdown is rendered to static HTML at build time.

```markdown
pages/index.md -> index.html post build
pages/subpages/subpage.md -> subpages/subpage.html post build

<!--
Supports HTML style Comments
-->

To change the title of the page, just add this to the top of the file.

<!--
Title: Page Title
-->
```

### Templates

There will be inevitably times when you want to add new stylesheets to the project, or include external scripts, in those cases, the power of plain HTML can come in handy. You can use the template pre-provided in the `templates` directory or create new ones for each page.

If you have a page `post-1.md`, you can create a `templates/post-1.html` file and it will be picked up, if a matching template name is not found, the builder defaults to the `templates/index.html` file. If no templates are found, the html output generated is a simple conversion of the markdown to HTML.

An example of a template is:

```html
<html>
	<head>
		<title>{{ title }}</title>
		<!-- Add your desired stylesheets here -->
	</head>
	<body>
		<!-- This serves as a template for your file, 
			add stylesheets, 
			scripts or any other properties that you need common in your pages.
		-->
		{{ content }}
	</body>
</html>
```

`{{ title }}` and `{{ content }}` are dynamically replaced with the title and content of the page at build time, support for more dynamic fields coming soon.

### Static Assets

Put your static assets like images, videos and other files in the `public` folder. They are automatically moved to the build output and are available in the same directory as the finally built pages.

### Environment Variables

Although a markdown based file should not have environment variables, you can use environment variables in templates.

Make sure to start your environment variables with `STRATIFY_APP_` and save them in `.env` file.

```html
<html>
	<head>
		<title>{{ title }}</title>
		<!-- Add your desired stylesheets here -->
	</head>
	<body>
		<!-- This serves as a template for your file, 
			add stylesheets, 
			scripts or any other properties that you need common in your pages.
		-->
		{{ content }}
	</body>
	<script type="text/javascript">
		const variable = process.env.STRATIFY_APP_ENV_VARIABLE;
	</script>
</html>
```

### Building your project

```bash
stratify build
```

This compiles your markdown pages to HTML and puts them in the `build` folder. This folder can then be served through a CDN or hosting provider like Vercel, Netlify since it's completely static.

### Serving Build Output

Once the build for your project is complete, you can run:

```bash
stratify start
```

It internally uses [serve](https://npmjs.com/serve) to serve the build output.

### Running the dev server

The dev server has hot reloading enabled for development ease. Run the following command:

```bash
stratify dev
```

### Contribution & Issues

[Raise an issue](https://github.com/deve-sh/stratify/issues/new)

[Create a Pull Request](https://github.com/deve-sh/stratify/compare)

Contributions and feedback are welcome, this is a weekend project built out of curiousity, any good changes will be merged.

---
_Source: https://npm.io/package/stratify-web · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
