|
1 | 1 | # Genja |
2 | 2 |
|
3 | | -Genja is a simple static site generator for GitHub Pages. It is a command line tool built in Python that generates HTML files and a JSON feed from Markdown content. |
| 3 | +Genja is a simple static website generator. It is a command line tool built in Python that generates HTML files and a JSON feed from Markdown content. |
4 | 4 |
|
5 | 5 | ## Installation |
6 | 6 |
|
7 | | -Download and install Python from [python.org](https://www.python.org) or from [Anaconda](https://www.anaconda.com). Next, install genja from [PyPI](https://pypi.org) using the following command: |
| 7 | +Download and install Python from [python.org](https://www.python.org) or from [Anaconda](https://www.anaconda.com). Next, install Genja from [PyPI](https://pypi.org) using the following command: |
8 | 8 |
|
9 | | -``` |
| 9 | +```text |
10 | 10 | pip install genja |
11 | 11 | ``` |
12 | 12 |
|
13 | 13 | Check the installed version from the command line: |
14 | 14 |
|
15 | | -``` |
| 15 | +```text |
16 | 16 | genja --version |
17 | 17 | ``` |
18 | 18 |
|
19 | 19 | ## Usage |
20 | 20 |
|
21 | | -Before running genja, create a project structure as shown below. The `content` directory contains Markdown files that are used to generate HTML files. The `templates` directory contains [Jinja](https://jinja.palletsprojects.com/) templates that are used to render the HTML pages. The `docs` directory contains the built website which can be hosted with GitHub Pages. Lastly, the `config.json` defines the URLs and directories for the project. |
| 21 | +Before running Genja, create a project structure as shown below. The `content` directory contains Markdown files that are used to generate HTML files. The `templates` directory contains [Jinja2](https://jinja.palletsprojects.com/) templates that are used to render the HTML pages. The `docs` directory contains the generated website which can be hosted with GitHub Pages. Lastly, the `config.toml` defines the base URL and directories for the project. |
22 | 22 |
|
23 | | -``` |
| 23 | +```text |
24 | 24 | mywebsite/ |
25 | 25 | |- content/ |
26 | 26 | |- templates/ |
27 | 27 | |- docs/ |
28 | | -|- config.json |
| 28 | +|- config.toml |
29 | 29 | ``` |
30 | 30 |
|
31 | | -The items in the `config.json` are shown below. The `base_url` is the URL for the homepage of the website. Markdown files that are parsed by genja are located in the `input_dir` directory. The HTML files generated from genja are located in the `output_dir` directory. Static content such as images and CSS files should go in the output directory. |
| 31 | +The items in the `config.toml` are shown below. The `base_url` is the URL for the homepage of the website. Markdown files that are parsed by Genja are located in the `markdown_dir` directory. The Jinja2 templates used by Genja are located in the `template_dir` directory. The HTML files generated from Genja are located in the `output_dir` directory. Static content such as images and CSS files should go in the output directory. |
32 | 32 |
|
33 | | -```json |
34 | | -{ |
35 | | - "base_url": "https://example.com/mywebsite", |
36 | | - "input_dir": "content", |
37 | | - "output_dir": "docs" |
38 | | -} |
| 33 | +```toml |
| 34 | +base_url = "https://example.com/mywebsite" |
| 35 | +markdown_dir = "content" |
| 36 | +template_dir = "templates" |
| 37 | +output_dir = "docs" |
39 | 38 | ``` |
40 | 39 |
|
41 | 40 | Use the serve command to build the website and start a local server. This will automatically open the default web browser to view the website. The website will automatically reload when changes are saved to the Markdown files. |
42 | 41 |
|
43 | | -``` |
| 42 | +```text |
44 | 43 | genja serve |
45 | 44 | ``` |
46 | 45 |
|
47 | 46 | Use the build command to build the website without running a local server. |
48 | 47 |
|
49 | | -``` |
| 48 | +```text |
50 | 49 | genja build |
51 | 50 | ``` |
52 | 51 |
|
53 | | -## Example |
54 | | - |
55 | | -To run the example, go to the `example` directory in this repository. The `mdcontent` folder is the input directory containing the Mardkown files. The `website` folder is the output directory containing the built HTML files. Use the commands shown below to build the website and run a local server to view the website in the default web browser. The website will automatically reload in the web browser when changes are saved to the Markdown files. |
56 | | - |
57 | | -``` |
58 | | -cd example |
59 | | -genja serve |
60 | | -``` |
61 | | - |
62 | | -Use the commands shown below to build the example website without starting a local server. |
| 52 | +## Examples |
63 | 53 |
|
64 | | -``` |
65 | | -cd example |
66 | | -genja build |
67 | | -``` |
| 54 | +See the `examples` directory in this repository for two example projects that can be built with Genja. The `directory-website` example uses the `website` directory for the generated output. The `toplevel-output` example uses the top-level of the project for the generated output. |
68 | 55 |
|
69 | 56 | ## Contributing |
70 | 57 |
|
71 | | -Clone this repository and use the conda environment file to create a Python environment for developing genja. This environment uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting along with [pytest](https://docs.pytest.org) for running tests. Genja is installed in editable mode within the environment. |
| 58 | +Clone this repository and use the conda environment file to create a Python environment for developing Genja. This environment uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting along with [pytest](https://docs.pytest.org) for running tests. Genja is installed in editable mode within the environment. |
72 | 59 |
|
73 | 60 | ```bash |
74 | 61 | # Clone this project |
|
0 commit comments