1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 11:34:46 +01:00
gojekyll/README.md

211 lines
9.2 KiB
Markdown
Raw Normal View History

2017-07-01 19:34:32 +02:00
# Gojekyll
2017-07-02 05:54:12 +02:00
2017-06-13 18:47:59 +02:00
[![Build Status](https://travis-ci.org/osteele/gojekyll.svg?branch=master)](https://travis-ci.org/osteele/gojekyll)
2017-06-12 02:05:38 +02:00
[![Go Report Card](https://goreportcard.com/badge/github.com/osteele/gojekyll)](https://goreportcard.com/report/github.com/osteele/gojekyll)
2017-07-02 02:49:15 +02:00
Gojekyll is an incomplete implementation of the [Jekyll](https://jekyllrb.com) static site generator, in the [Go](https://golang.org) programming language.
2017-07-02 02:35:05 +02:00
2017-07-02 02:49:15 +02:00
This was my “weekend project” for learning Go. It took on a life of its own (and more than a weekend).
2017-07-01 19:34:32 +02:00
2017-07-02 02:24:11 +02:00
<!-- TOC -->
2017-07-01 19:34:32 +02:00
2017-07-02 02:24:11 +02:00
- [Gojekyll](#gojekyll)
- [Installation](#installation)
- [Usage](#usage)
- [Status](#status)
2017-07-02 02:49:15 +02:00
- [Major Omissions](#major-omissions)
2017-07-02 02:35:05 +02:00
- [Other Caveats](#other-caveats)
- [Intentional Differences](#intentional-differences)
- [Timings](#timings)
- [Features](#features)
2017-07-02 02:24:11 +02:00
- [Contributing](#contributing)
- [Testing](#testing)
- [Profiling](#profiling)
- [Credits](#credits)
- [Related](#related)
- [License](#license)
<!-- /TOC -->
2017-07-02 02:35:05 +02:00
## Installation
1. [Install go](https://golang.org/doc/install#install). On macOS running Homebrew, `brew install go` is easier than the linked instructions.
2. `go get -u osteele/gojekyll/cmd/gojekyll`
3. To use the `{% highlight %}` tag, you need to install Pygments: `pip install Pygments`.
## Usage
```bash
gojekyll -s path/to/site build # builds into ./_site
gojekyll -s path/to/site serve # serves from memory, w/ live reload
gojekyll help
gojekyll help build
```
## Status
2017-07-02 02:24:11 +02:00
2017-07-02 02:49:15 +02:00
### Major Omissions
2017-07-02 02:24:11 +02:00
2017-07-02 05:06:47 +02:00
- Major features: themes, page tags, excerpts, plugins (except for a few listed below), pagination, math, warning mode.
2017-07-01 19:34:32 +02:00
- Site variables: `pages`, `static_files`, `html_pages`, `html_files`, `documents`, and `tags`
2017-07-02 02:35:05 +02:00
- Jekyll filters: `group_by_exp`, `pop`, `shift`, `cgi_escape`, `uri_escape`, `scssify`, and `smartify`.
2017-07-02 05:06:47 +02:00
- Jekyll's `include_relative` tag
- The Go Liquid engine is also missing some tags and a few filters. See its [README](https://github.com/osteele/gojekyll/#status) for status.
2017-07-02 02:35:05 +02:00
- Data files must be YAML. CSV and JSON are not (yet) supported.
- `{% highlight %}` uses Pygments. There's no way to tell it to use Rouge. Also, I don't know what will happen if Pygments isn't installed.
- `<div markdown=1>` doesn't work. I think this is a limitation of the Blackfriday Markdown processor.
### Other Caveats
2017-07-02 05:06:47 +02:00
- This Liquid engine is probably much stricter than the original.
- Both the Liquid and Jekyll implementations are much less robust than the originals. They probably panic or otherwise fails on a lot of legitimate constructs.
2017-07-02 02:24:11 +02:00
- Liquid errors aren't reported very nicely.
2017-07-01 19:34:32 +02:00
2017-07-02 02:35:05 +02:00
### Intentional Differences
2017-07-01 19:34:32 +02:00
- `serve` generates pages on the fly; it doesn't write to the file system.
2017-07-02 00:11:35 +02:00
- Files are cached to `/tmp/gojekyll-${USER}`, not `./.sass-cache`
2017-07-01 19:34:32 +02:00
- Server live reload is always on.
2017-07-02 05:06:47 +02:00
- The server reloads the `_config.yml` (and the rest of the site) when that file changes.
2017-07-02 01:42:48 +02:00
- `build` with no `-d` option resolves the destination relative to the source directory, not the current directory.
2017-07-01 19:34:32 +02:00
2017-07-02 02:24:11 +02:00
### Timings
`[go]jekyll -s jekyll/docs build`
| Executable | Options | Time |
|------------|--------------------------------------|--------|
| jekyll | | 18.53s |
| gojekyll | single-threaded; cold cache | 6.85s |
| gojekyll | single-threaded; warm cache | 0.61s |
| gojekyll | multi-threaded; cache doesn't matter | 0.34s |
There's currently no way to disable concurrency or the cache. They were switched off by editing the code for these timings.
2017-07-02 05:06:47 +02:00
The cache is for calls to Pygments (via the `highlight` tag).
2017-07-02 02:24:11 +02:00
2017-07-02 02:35:05 +02:00
### Features
2017-06-19 01:12:33 +02:00
- [ ] Content
- [x] Front Matter
- [ ] Posts
2017-07-01 15:35:26 +02:00
- [x] Categories
2017-06-19 01:12:33 +02:00
- [ ] Tags
2017-07-01 23:46:18 +02:00
- [x] Drafts
- [x] Future
2017-07-01 04:05:55 +02:00
- [x] Related
2017-06-19 01:12:33 +02:00
- [x] Static Files
- [x] Variables
2017-06-22 14:34:37 +02:00
- [x] Collections
2017-06-19 01:12:33 +02:00
- [ ] Data Files
2017-06-19 20:44:34 +02:00
- [ ] CSV
- [ ] JSON
- [x] YAML
2017-06-19 01:12:33 +02:00
- [ ] Assets
- [ ] Coffeescript
2017-06-19 04:24:10 +02:00
- [x] Sass/SCSS
2017-06-19 01:12:33 +02:00
- [ ] Customization
- [x] Templates
2017-06-29 15:41:33 +02:00
- [ ] Jekyll filters
2017-07-01 04:38:27 +02:00
- [ ] `group_by_exp` `pop` `shift` `cgi_escape` `uri_escape` `scssify` `smartify`
2017-06-29 15:41:33 +02:00
- [x] everything else
- [ ] Jekyll tags
- [x] `include`
- [ ] `include_relative`
- [x] `link`
2017-07-01 23:46:18 +02:00
- [x] `post_url`
2017-06-29 15:41:33 +02:00
- [ ] `gist`
2017-07-01 23:46:18 +02:00
- [x] `highlight`
2017-06-19 01:12:33 +02:00
- [x] Includes
2017-06-29 15:41:33 +02:00
- [x] `include` parameters
2017-07-01 23:46:18 +02:00
- [x] `include` variables (e.g. `{% include {{ expr }} %}`)
2017-06-19 01:12:33 +02:00
- [x] Permalinks
- [ ] Pagination
2017-07-01 19:34:32 +02:00
- [ ] Plugins
- [x] `jekyll-avatar`
- [ ] `jekyll-coffeescript`
2017-07-02 05:06:47 +02:00
- [x] `jekyll-gist` (ignores `noscript: false`)
2017-07-01 19:34:32 +02:00
- [x] `jekyll-live-reload` (always on)
- [ ] `jekyll-paginate`
2017-06-19 01:12:33 +02:00
- [ ] Themes
- [x] Layouts
- [x] Server
- [x] Directory watch
2017-07-01 19:34:32 +02:00
- [ ] Commands
- [x] `build`
2017-07-01 21:13:32 +02:00
- [x] `--source`, `--destination`, `--drafts`, `--future`, `--unpublished`
2017-07-02 01:42:48 +02:00
- [ ] `--config`, `--baseurl`, `--lsi`, `--watch`, etc.
- [ ] won't implement: `--force-polling`, `--limit-posts`, `--incremental`, `JEKYLL_ENV=production`
2017-07-01 19:34:32 +02:00
- [x] `clean`
- [ ] `doctor`
- [x] `help`
- [ ] `import`
- [ ] `new`
- [ ] `new-theme`
- [x] `serve`
- [x] `--open-uri`
2017-07-02 01:42:48 +02:00
- [ ] `--detach`, `--host`, `--port`, `--baseurl`
- [ ] won't implement: `--incremental`, `--ssl-*`
2017-06-29 15:41:33 +02:00
- [ ] Windows
2017-06-23 16:27:57 +02:00
## Contributing
2017-06-20 15:00:04 +02:00
Install package dependencies and development tools:
```bash
make setup
```
2017-06-23 16:27:57 +02:00
### Testing
2017-06-19 15:15:52 +02:00
2017-06-19 20:03:51 +02:00
```bash
2017-06-20 15:00:04 +02:00
make test
make lint
2017-06-23 16:27:57 +02:00
gojekyll -s path/to/site render index.md # render a file to stdout
gojekyll -s path/to/site render / # render a URL to stdout
gojekyll -s path/to/site variables / # print a file or URL's variables
2017-06-22 23:53:46 +02:00
./scripts/coverage && go tool cover -html=coverage.out
2017-06-19 20:03:51 +02:00
```
2017-06-19 15:15:52 +02:00
`./scripts/gojekyll` is an alternative to the `gojekyll` executable, that uses `go run` each time it's invoked.
2017-06-23 16:27:57 +02:00
### Profiling
2017-06-19 15:15:52 +02:00
```bash
2017-06-23 16:27:57 +02:00
gojekyll -s path/to/site profile
2017-06-19 15:15:52 +02:00
go tool pprof gojekyll gojekyll.prof
```
2017-06-12 00:59:02 +02:00
## Credits
2017-06-29 13:08:37 +02:00
Gojekyll uses these libraries:
2017-06-20 15:00:04 +02:00
2017-07-02 02:24:11 +02:00
| Package | Author(s) | Description | License |
|--------------------------------------------------------------------------------|--------------------------------------------------------|-------------------------------------------------------|-----------------------------------|
| [github.com/jaschaephraim/lrserver](https://github.com/jaschaephraim/lrserver) | Jascha Ephraim | Live Reload server | MIT |
| [github.com/osteele/liquid](https://github.com/osteele/liquid) | yours truly | Liquid processor | MIT |
| [github.com/pkg/browser](https://github.com/pkg/browser) | [pkg](https://github.com/pkg) | The `serve -o` option to open the site in the browser | BSD 2-clause "Simplified" License |
| [github.com/russross/blackfriday](https://github.com/russross/blackfriday) | Russ Ross | Markdown processor | Simplified BSD License |
| [github.com/sass/libsass](https://github.com/sass/libsass) | Listed [here](https://https://github.com/sass/libsass) | C port of the Ruby SASS compiler | MIT |
| [github.com/wellington/go-libsass](https://github.com/wellington/go-libsass) | Drew Wells | Go bindings for **libsass** | ??? |
| [gopkg.in/alecthomas/kingpin.v2](https://github.com/alecthomas/kingpin) | Alec Thomas | command line and flag parser | MIT |
| [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) | Canonical | YAML support | Apache License 2.0 |
2017-06-29 13:08:37 +02:00
2017-07-02 05:06:47 +02:00
In addition to being totally and obviously inspired by Jekyll, Jekyll's *documentation* was solid and indispensible. Many of the filter test cases are taken directly from the Jekyll documentation, and during development the [Jekyll docs](https://jekyllrb.com/docs/home/) were always open in at least one tab.
2017-06-22 01:19:08 +02:00
2017-07-02 05:06:47 +02:00
The text for `gojekyll help` was taken from the output of `jekyll help`.
2017-07-01 20:55:50 +02:00
2017-07-02 05:06:47 +02:00
The gopher image in the `testdata` directory is from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Gophercolor.jpg). It is used under the [Creative Commons Attribution-Share Alike 3.0 Unported license](https://creativecommons.org/licenses/by-sa/3.0/deed.en).
2017-06-12 03:05:17 +02:00
2017-06-12 00:59:02 +02:00
## Related
2017-07-02 05:06:47 +02:00
[Hugo](https://gohugo.io) is *the* pre-eminent Go static site generator. It isn't Jekyll-compatible (-), but it's extraordinarily polished, performant, and productized (+++).
2017-06-12 00:59:02 +02:00
2017-07-02 05:06:47 +02:00
[Liquid](https://github.com/osteele/liquid) is a Go implementation of Liquid templates. I wrote it for gojekyll, but it's implemented as a standalone library.
2017-07-02 02:24:11 +02:00
2017-06-12 02:30:25 +02:00
[Jekyll](https://jekyllrb.com), of course.
2017-06-12 00:59:02 +02:00
## License
MIT