|
| 1 | +# Contributing to GRASS tutorials |
| 2 | + |
| 3 | +We welcome various contributions — fixing a typo, improving clarity, or adding a new tutorial. |
| 4 | +Not sure where to begin? [Open an issue](https://github.com/OSGeo/grass-tutorials/issues) to start a conversation. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Getting started |
| 9 | + |
| 10 | +1. **Fork and clone** the repository. Then follow the |
| 11 | +[GitHub guide](https://grass.osgeo.org/grass-devel/manuals/github_guide.html) for the GRASS repository and adjust the workflow for this repository. |
| 12 | + |
| 13 | +2. **Install Quarto** (if you haven’t already), see <https://quarto.org/docs/get-started/> |
| 14 | + |
| 15 | +3. **Preview the site locally:** |
| 16 | + |
| 17 | + ```sh |
| 18 | + quarto preview |
| 19 | + ``` |
| 20 | + |
| 21 | + This launches a local server and opens a live preview in your browser. |
| 22 | + |
| 23 | +4. **Create or edit tutorials:** |
| 24 | + |
| 25 | + Tutorials are written in Markdown (.qmd) with YAML front matter. |
| 26 | + |
| 27 | + Add your tutorial to the appropriate section (e.g., ./content/tutorials/mytutorials). |
| 28 | + |
| 29 | +## Writing a tutorial |
| 30 | + |
| 31 | +Give your audience some context, for example include what topics does |
| 32 | +the tutorial cover, what are the prerequisites, and so on. |
| 33 | + |
| 34 | +Use Quarto's [guide](https://quarto.org/docs/guide/) to learn how to write |
| 35 | +Quarto documents and learn [Markdown syntax](https://quarto.org/docs/authoring/markdown-basics.html). |
| 36 | +
|
| 37 | +For example, include GRASS commands in fenced code blocks: |
| 38 | +
|
| 39 | +```` markdown |
| 40 | +```{python} |
| 41 | +gs.run_command("g.region", raster="elevation") |
| 42 | +``` |
| 43 | +```` |
| 44 | +
|
| 45 | +You can use [tabsets](https://quarto.org/docs/output-formats/html-basics.html#tabsets) |
| 46 | +to show how to run GRASS commands in command line and in Python: |
| 47 | +
|
| 48 | +```` markdown |
| 49 | +::: {.panel-tabset group="language"} |
| 50 | +
|
| 51 | +## Command line |
| 52 | +
|
| 53 | +```{bash} |
| 54 | +g.region raster=elevation |
| 55 | +``` |
| 56 | +
|
| 57 | +## Python |
| 58 | +
|
| 59 | +```{python} |
| 60 | +gs.run_command("g.region", raster="elevation") |
| 61 | +``` |
| 62 | +
|
| 63 | +::: |
| 64 | +```` |
| 65 | +
|
| 66 | +Display notes: |
| 67 | +
|
| 68 | +``` markdown |
| 69 | +::: {.callout-note title="Setup"} |
| 70 | +To run this tutorial locally ... |
| 71 | +::: |
| 72 | +``` |
| 73 | +
|
| 74 | +## YAML metadata example |
| 75 | +
|
| 76 | +Each tutorial must begin with YAML metadata like this: |
| 77 | +
|
| 78 | +```` yaml |
| 79 | +--- |
| 80 | +title: "Computing slope from elevation data in Python" |
| 81 | +author: "Your Name" |
| 82 | +date: "2025-05-15" |
| 83 | +description: "Learn how to derive slope from elevation data in GRASS in a Jupyter Notebook." |
| 84 | +categories: ["beginner", "geomorphometry", Python] |
| 85 | +thumbnail: slope_thumbnail.webp |
| 86 | +format: |
| 87 | + ipynb: default |
| 88 | + html: |
| 89 | + toc: true |
| 90 | + code-tools: true |
| 91 | + code-copy: true |
| 92 | + code-fold: false |
| 93 | +engine: jupyter |
| 94 | +execute: |
| 95 | + eval: false |
| 96 | +jupyter: python3 |
| 97 | +--- |
| 98 | +
|
| 99 | +```` |
| 100 | +
|
| 101 | +Notes: |
| 102 | +
|
| 103 | +- Use appropriate categories (tags), include whether the tutorial is for *beginner*, *intermediate*, or *advanced* users. |
| 104 | +
|
| 105 | +- Use `eval: false` so that Quarto doesn't run the code during building of the website. |
| 106 | + |
| 107 | +- Specifying format `ipynb: default` will create a Jupyter notebook during the build process and link it from the tutorial page. |
| 108 | + |
| 109 | +## Images |
| 110 | + |
| 111 | +Beautiful images and graphics make tutorials stand out! |
| 112 | +Make sure the images have *sufficient resolution*. |
| 113 | +At the same time, their size should not be too big to load quickly, try to keep it under 200 KB or so. We recommend using *webp* format. |
| 114 | + |
| 115 | +``` markdown |
| 116 | + |
| 117 | +``` |
| 118 | + |
| 119 | +Each tutorial needs to have at least one image that can be used on the main page as a thumbnail. |
| 120 | +You can either specify it in the YAML header (`thumbnail: image.webp`) or add `{.preview-image}` to the image. |
| 121 | + |
| 122 | +``` markdown |
| 123 | +{.preview-image} |
| 124 | +``` |
| 125 | + |
| 126 | +## Submitting your contribution |
| 127 | + |
| 128 | +Check your markdown with a [linter](https://dlaa.me/markdownlint/) and fix as many issues as you can. This will help keeping the tutorials consistent. |
| 129 | + |
| 130 | +Follow the [GitHub guide](https://grass.osgeo.org/grass-devel/manuals/github_guide.html) |
| 131 | +(adapt it to this repo) to submit your tutorial. |
| 132 | +You should **only commit the .qmd file and images**. |
| 133 | +Once you sumbmit a PR, the CI pipeline will build your |
| 134 | +tutorial, so you and a reviewer can check if everything is ok. |
| 135 | +When a reviewer approves, your PR will be merged soon. |
| 136 | + |
| 137 | +--- |
| 138 | +Thanks for helping us build better educational resources for the GRASS community! |
0 commit comments