|
1 | | -# Learning track |
| 1 | +# Learning Tracks |
2 | 2 |
|
3 | | -Learning tracks display on guides pages. Learning tracks are a list of related articles that learners can go through sequentially. |
| 3 | +This module manages "Learning Tracks"—curated, ordered lists of articles that guide a user through a specific topic or goal. When a user enters a learning track, they see a persistent banner or navigation element that helps them move sequentially through the guides. |
| 4 | + |
| 5 | +## Purpose & Scope |
| 6 | + |
| 7 | +The goal of this feature is to: |
| 8 | +- **Group Content**: Logically group related articles into a sequence. |
| 9 | +- **Guide Users**: Provide "Next" and "Previous" navigation context to keep users on the path. |
| 10 | +- **Track Progress**: Visually indicate where the user is within the sequence (e.g., "Step 2 of 5"). |
| 11 | + |
| 12 | +## Architecture |
| 13 | + |
| 14 | +### Data Source |
| 15 | + |
| 16 | +Learning tracks are defined in YAML files located in `data/learning-tracks`. |
| 17 | +- **Structure**: `data/learning-tracks/<product>.yml` |
| 18 | +- **Schema**: Each file contains multiple tracks, where each track is defined as a top-level key with properties like: |
| 19 | + - `title`: Display title of the track. |
| 20 | + - `description`: Short summary. |
| 21 | + - `guides`: An ordered list of relative paths to the articles. |
| 22 | + - `versions`: (Optional) Which versions this track applies to. |
| 23 | + |
| 24 | +### Middleware |
| 25 | + |
| 26 | +The core logic for *active* tracking happens in `src/learning-track/middleware/learning-track.ts`. |
| 27 | +- **Trigger**: It looks for the `?learn=<track_name>` query parameter in the URL. |
| 28 | +- **Context Injection**: If a valid track is found: |
| 29 | + - It calculates the current position (index) based on the current page path. |
| 30 | + - It resolves the `prevGuide` and `nextGuide` links. |
| 31 | + - It injects a `currentLearningTrack` object into `req.context`, which the UI components use to render the progress banner. |
| 32 | + |
| 33 | +### Library |
| 34 | + |
| 35 | +`src/learning-track/lib/process-learning-tracks.ts` is used (often by landing pages) to list available tracks. |
| 36 | +- **Rendering**: It handles Liquid rendering for titles and descriptions. |
| 37 | +- **Versioning**: It filters out tracks or specific guides that don't exist in the current documentation version. |
| 38 | +- **Translation Fallback**: It ensures that if a translated track has broken data, it falls back to the English structure (guides list) while keeping translated titles if possible. |
| 39 | + |
| 40 | +## Setup & Usage |
| 41 | + |
| 42 | +### Defining a Track |
| 43 | + |
| 44 | +Add a track to `data/learning-tracks/YOUR_PRODUCT.yml`: |
| 45 | + |
| 46 | +```yaml |
| 47 | +getting_started: |
| 48 | + title: "Getting Started with GitHub" |
| 49 | + description: "Learn the basics of repositories and commits." |
| 50 | + versions: |
| 51 | + fpt: '*' |
| 52 | + ghec: '*' |
| 53 | + guides: |
| 54 | + - /get-started/signing-up-for-github/signing-up-for-a-new-github-account |
| 55 | + - /get-started/first-steps-with-git/set-up-git |
| 56 | +``` |
| 57 | +
|
| 58 | +### Linking to a Track |
| 59 | +
|
| 60 | +To start a user on a track, link to the first guide with the `learn` parameter (matching the track key defined in the YAML): |
| 61 | +`/en/get-started/signing-up-for-github/signing-up-for-a-new-github-account?learn=getting_started` |
| 62 | + |
| 63 | +### URL Structure |
| 64 | + |
| 65 | +- **`learn=<track_name>`**: Identifies the active track. |
| 66 | +- **`learnProduct=<product_name>`**: (Optional) Used when the track belongs to a different product than the current page context. |
| 67 | + |
| 68 | +## Dependencies |
| 69 | + |
| 70 | +- **`data/learning-tracks`**: The source of truth for track definitions. |
| 71 | +- **`src/content-render`**: Used to render Liquid within track titles and descriptions. |
| 72 | +- **`src/versions`**: Used to filter tracks based on the current page version. |
| 73 | + |
| 74 | +## Ownership |
| 75 | + |
| 76 | +- **Team**: `@github/docs-engineering` |
| 77 | +- **Content Owners**: The Writers and Content Strategists who define the tracks in the `data` directory. |
| 78 | + |
| 79 | +## Current State & Known Issues |
| 80 | + |
| 81 | +- **Query Param Persistence**: The feature relies on the `?learn=` parameter persisting as the user clicks links. If a user navigates away via a link that doesn't preserve query params (e.g., a standard markdown link outside the track navigation), they "fall off" the track. |
| 82 | +- **Translation Sync**: Translators sometimes translate the `guides` list paths or break the YAML structure. The code has specific logic to force-use English guide lists to prevent 404s in translated versions. |
0 commit comments