|
| 1 | +# Adding Pages |
| 2 | + |
| 3 | +This guide explains how to create new pages and content for the Node.js website. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Page Creation Process](#page-creation-process) |
| 8 | + - [1. Create the Page Content](#1-create-the-page-content) |
| 9 | + - [2. Configure the Frontmatter](#2-configure-the-frontmatter) |
| 10 | + - [3. Choose the Appropriate Layout](#3-choose-the-appropriate-layout) |
| 11 | + - [4. Update Navigation (if needed)](#4-update-navigation-if-needed) |
| 12 | +- [Adding Learn Pages](#adding-learn-pages) |
| 13 | + - [Learn Page Structure](#learn-page-structure) |
| 14 | + - [Learn Page Frontmatter](#learn-page-frontmatter) |
| 15 | + - [Frontmatter Fields](#frontmatter-fields) |
| 16 | + - [Update Learn Navigation](#update-learn-navigation) |
| 17 | + - [Add Translation Keys](#add-translation-keys) |
| 18 | +- [Content Guidelines](#content-guidelines) |
| 19 | + - [Markdown Features](#markdown-features) |
| 20 | + - [Code Blocks](#code-blocks) |
| 21 | + - [Multiple Code Tabs](#multiple-code-tabs) |
| 22 | + - [Accessible Components](#accessible-components) |
| 23 | +- [File Organization](#file-organization) |
| 24 | + - [Content Structure](#content-structure) |
| 25 | + - [Asset Management](#asset-management) |
| 26 | +- [Internationalization](#internationalization) |
| 27 | + - [Translation Process](#translation-process) |
| 28 | + - [Translation Guidelines](#translation-guidelines) |
| 29 | +- [Page Types and Examples](#page-types-and-examples) |
| 30 | + - [Standard Content Page](#standard-content-page) |
| 31 | + - [Blog Post](#blog-post) |
| 32 | + - [Learn Article](#learn-article) |
| 33 | +- [Validation and Testing](#validation-and-testing) |
| 34 | + - [Before Publishing](#before-publishing) |
| 35 | + - [Content Review](#content-review) |
| 36 | +- [Advanced Features](#advanced-features) |
| 37 | + - [Custom Layouts](#custom-layouts) |
| 38 | + - [Dynamic Content](#dynamic-content) |
| 39 | + |
| 40 | +## Page Creation Process |
| 41 | + |
| 42 | +### 1. Create the Page Content |
| 43 | + |
| 44 | +Create a new markdown file in `apps/site/pages/en/` with the appropriate subdirectory structure. |
| 45 | + |
| 46 | +```markdown |
| 47 | +--- |
| 48 | +title: Title of the Page |
| 49 | +layout: layout-name |
| 50 | +--- |
| 51 | + |
| 52 | +# Page Title |
| 53 | + |
| 54 | +Your content goes here... |
| 55 | +``` |
| 56 | + |
| 57 | +### 2. Configure the Frontmatter |
| 58 | + |
| 59 | +The frontmatter (YAML block at the top) configures page metadata: |
| 60 | + |
| 61 | +- `title`: The page title displayed in the browser tab and used for SEO |
| 62 | +- `layout`: The layout template to use (see available layouts below) |
| 63 | +- `description`: Optional meta description for SEO |
| 64 | +- `authors`: For learn pages, list of GitHub usernames |
| 65 | + |
| 66 | +### 3. Choose the Appropriate Layout |
| 67 | + |
| 68 | +Available layouts are defined in `apps/site/layouts/`. Common layouts include: |
| 69 | + |
| 70 | +- `page`: Default layout for most content pages |
| 71 | +- `blog`: For blog posts and announcements |
| 72 | +- `learn`: For educational content and tutorials |
| 73 | +- `download`: For download-related pages |
| 74 | +- `docs`: For API documentation |
| 75 | + |
| 76 | +> **Note**: Layout components are currently mapped in `components/withLayout`. This location may change in future updates. |
| 77 | +
|
| 78 | +### 4. Update Navigation (if needed) |
| 79 | + |
| 80 | +If your page should appear in the site navigation, update the relevant layout or navigation configuration: |
| 81 | + |
| 82 | +- Main navigation: Update `apps/site/layouts` components |
| 83 | +- Learn section: Update `app/site/navigation.json` |
| 84 | + |
| 85 | +## Adding Learn Pages |
| 86 | + |
| 87 | +The Learn section has special requirements and structure. |
| 88 | + |
| 89 | +### Learn Page Structure |
| 90 | + |
| 91 | +``` |
| 92 | +apps/site/pages/en/learn/ |
| 93 | +├── category-name/ |
| 94 | +│ ├── article-name.md |
| 95 | +│ └── another-article.md |
| 96 | +└── another-category/ |
| 97 | + └── article.md |
| 98 | +``` |
| 99 | + |
| 100 | +### Learn Page Frontmatter |
| 101 | + |
| 102 | +```yaml |
| 103 | +--- |
| 104 | +title: A Super Cool Tutorial |
| 105 | +layout: learn |
| 106 | +authors: github_username, another_github_username |
| 107 | +--- |
| 108 | +``` |
| 109 | + |
| 110 | +#### Frontmatter Fields |
| 111 | + |
| 112 | +- `title`: Article title (use same as navigation entry) |
| 113 | +- `layout`: Must be set to `learn` |
| 114 | +- `authors`: Comma-separated list of GitHub usernames (used for profile pictures) |
| 115 | + |
| 116 | +### Update Learn Navigation |
| 117 | + |
| 118 | +Add your new article to `app/site/navigation.json`: |
| 119 | + |
| 120 | +```json |
| 121 | +{ |
| 122 | + "sideNavigation": { |
| 123 | + "learn": [ |
| 124 | + { |
| 125 | + "label": "Category Name", |
| 126 | + "items": { |
| 127 | + "articleName": { |
| 128 | + "link": "/learn/category-name/article-name", |
| 129 | + "label": "components.navigation.learn.category-name.article-name" |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + ] |
| 134 | + } |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +### Add Translation Keys |
| 139 | + |
| 140 | +Create translation keys for your navigation entries in the appropriate locale files: |
| 141 | + |
| 142 | +```json |
| 143 | +// packages/i18n/locales/en.json |
| 144 | +{ |
| 145 | + "components": { |
| 146 | + "navigation": { |
| 147 | + "learn": { |
| 148 | + "category-name": { |
| 149 | + "article-name": "Your Article Title" |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | +} |
| 155 | +``` |
| 156 | + |
| 157 | +## Content Guidelines |
| 158 | + |
| 159 | +### Markdown Features |
| 160 | + |
| 161 | +The website supports GitHub Flavored Markdown plus MDX components: |
| 162 | + |
| 163 | +- Standard Markdown syntax |
| 164 | +- Code blocks with syntax highlighting |
| 165 | +- Tables, lists, and formatting |
| 166 | +- Custom React components within content |
| 167 | + |
| 168 | +### Code Blocks |
| 169 | + |
| 170 | +Use fenced code blocks with language specification: |
| 171 | + |
| 172 | +````markdown |
| 173 | +```javascript |
| 174 | +const example = 'Hello World'; |
| 175 | +console.log(example); |
| 176 | +``` |
| 177 | +```` |
| 178 | + |
| 179 | +### Multiple Code Tabs |
| 180 | + |
| 181 | +Consecutive code blocks create tabbed interfaces: |
| 182 | + |
| 183 | +````markdown |
| 184 | +```cjs |
| 185 | +const http = require('node:http'); |
| 186 | +``` |
| 187 | + |
| 188 | +```mjs |
| 189 | +import http from 'node:http'; |
| 190 | +``` |
| 191 | +```` |
| 192 | + |
| 193 | +### Accessible Components |
| 194 | + |
| 195 | +Use built-in accessible components when needed: |
| 196 | + |
| 197 | +- **Codebox**: Automatic syntax highlighting and tabbed interfaces |
| 198 | +- **Links**: Use standard Markdown links for best accessibility |
| 199 | +- **Images**: Include descriptive alt text |
| 200 | + |
| 201 | +## File Organization |
| 202 | + |
| 203 | +### Content Structure |
| 204 | + |
| 205 | +``` |
| 206 | +apps/site/pages/ |
| 207 | +├── en/ # English content (source) |
| 208 | +│ ├── learn/ # Learn section |
| 209 | +│ ├── blog/ # Blog posts |
| 210 | +│ ├── download/ # Download pages |
| 211 | +│ └── about/ # About pages |
| 212 | +└── {locale}/ # Translated content |
| 213 | + └── ... # Same structure as en/ |
| 214 | +``` |
| 215 | + |
| 216 | +### Asset Management |
| 217 | + |
| 218 | +- **Images**: Store in `apps/site/public/static/images/` |
| 219 | +- **Documents**: Store in `apps/site/public/static/documents/` |
| 220 | +- **Icons**: Use existing icon system or add to `@node-core/ui-components/Icons/` |
| 221 | + |
| 222 | +## Internationalization |
| 223 | + |
| 224 | +### Translation Process |
| 225 | + |
| 226 | +1. Create the English version first in `apps/site/pages/en/` |
| 227 | +2. Translators will create localized versions in `apps/site/pages/{locale}/` |
| 228 | +3. Non-translated pages automatically fall back to English content with localized navigation |
| 229 | + |
| 230 | +### Translation Guidelines |
| 231 | + |
| 232 | +- Keep file paths consistent across locales |
| 233 | +- Use the same frontmatter structure |
| 234 | +- Reference the [Translation Guidelines](./translation.md) for detailed policies |
| 235 | + |
| 236 | +## Page Types and Examples |
| 237 | + |
| 238 | +### Standard Content Page |
| 239 | + |
| 240 | +```markdown |
| 241 | +--- |
| 242 | +title: About Node.js |
| 243 | +layout: page |
| 244 | +description: Learn about the Node.js runtime and its ecosystem |
| 245 | +--- |
| 246 | + |
| 247 | +# About Node.js |
| 248 | + |
| 249 | +Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine... |
| 250 | +``` |
| 251 | + |
| 252 | +### Blog Post |
| 253 | + |
| 254 | +```markdown |
| 255 | +--- |
| 256 | +title: Node.js 20.0.0 Released |
| 257 | +layout: blog |
| 258 | +date: 2023-04-18 |
| 259 | +author: Node.js Team |
| 260 | +--- |
| 261 | + |
| 262 | +# Node.js 20.0.0 Now Available |
| 263 | + |
| 264 | +We're excited to announce the release of Node.js 20.0.0... |
| 265 | +``` |
| 266 | + |
| 267 | +### Learn Article |
| 268 | + |
| 269 | +```markdown |
| 270 | +--- |
| 271 | +title: Getting Started with Node.js |
| 272 | +layout: learn |
| 273 | +authors: nodejs-team, community-contributor |
| 274 | +--- |
| 275 | + |
| 276 | +# Getting Started with Node.js |
| 277 | + |
| 278 | +This tutorial will guide you through... |
| 279 | +``` |
| 280 | + |
| 281 | +## Validation and Testing |
| 282 | + |
| 283 | +### Before Publishing |
| 284 | + |
| 285 | +1. **Preview locally**: Use `pnpm dev` to preview your changes |
| 286 | +2. **Check formatting**: Run `pnpm format` to ensure proper formatting |
| 287 | +3. **Validate links**: Ensure all internal links work correctly |
| 288 | +4. **Test responsive design**: Check page layout on different screen sizes |
| 289 | + |
| 290 | +### Content Review |
| 291 | + |
| 292 | +- Ensure content follows our style guide |
| 293 | +- Verify technical accuracy |
| 294 | +- Check for proper grammar and spelling |
| 295 | +- Confirm accessibility of any custom elements |
| 296 | + |
| 297 | +## Advanced Features |
| 298 | + |
| 299 | +### Custom Layouts |
| 300 | + |
| 301 | +To create a custom layout: |
| 302 | + |
| 303 | +1. Add your layout component to `apps/site/layouts/` |
| 304 | +2. Update the layout mapping in `apps/site/components/withLayout.tsx` |
| 305 | +3. Document the layout purpose and usage |
| 306 | + |
| 307 | +### Dynamic Content |
| 308 | + |
| 309 | +For pages that need dynamic data: |
| 310 | + |
| 311 | +1. Use build-time data fetching in `apps/site/next-data/` |
| 312 | +2. Configure data sources in the appropriate scripts |
| 313 | +3. Access data through layout props or context |
0 commit comments