|
| 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/`, and mapped in `components/withLayout`. |
| 69 | + |
| 70 | +### 4. Update Navigation (if needed) |
| 71 | + |
| 72 | +If your page should appear in the site navigation, update `app/site/navigation.json` as needed. |
| 73 | + |
| 74 | +## Adding Learn Pages |
| 75 | + |
| 76 | +The Learn section has special requirements and structure. |
| 77 | + |
| 78 | +### Learn Page Structure |
| 79 | + |
| 80 | +``` |
| 81 | +apps/site/pages/en/learn/ |
| 82 | +├── category-name/ |
| 83 | +│ ├── article-name.md |
| 84 | +│ └── another-article.md |
| 85 | +└── another-category/ |
| 86 | + └── article.md |
| 87 | +``` |
| 88 | + |
| 89 | +### Update Learn Navigation |
| 90 | + |
| 91 | +Add your new article to `app/site/navigation.json`: |
| 92 | + |
| 93 | +```json |
| 94 | +{ |
| 95 | + "sideNavigation": { |
| 96 | + "learn": [ |
| 97 | + { |
| 98 | + "label": "Category Name", |
| 99 | + "items": { |
| 100 | + "articleName": { |
| 101 | + "link": "/learn/category-name/article-name", |
| 102 | + "label": "components.navigation.learn.category-name.article-name" |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + ] |
| 107 | + } |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +### Add Translation Keys |
| 112 | + |
| 113 | +Create translation keys for your navigation entries in the appropriate locale files: |
| 114 | + |
| 115 | +```json |
| 116 | +// packages/i18n/locales/en.json |
| 117 | +{ |
| 118 | + "components": { |
| 119 | + "navigation": { |
| 120 | + "learn": { |
| 121 | + "category-name": { |
| 122 | + "article-name": "Your Article Title" |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Content Guidelines |
| 131 | + |
| 132 | +### Markdown Features |
| 133 | + |
| 134 | +The website supports GitHub Flavored Markdown plus MDX components: |
| 135 | + |
| 136 | +- Standard Markdown syntax |
| 137 | +- Code blocks with syntax highlighting |
| 138 | +- Tables, lists, and formatting |
| 139 | +- Custom React components within content |
| 140 | + |
| 141 | +### Code Blocks |
| 142 | + |
| 143 | +Use fenced code blocks with language specification: |
| 144 | + |
| 145 | +````markdown |
| 146 | +```javascript |
| 147 | +const example = 'Hello World'; |
| 148 | +console.log(example); |
| 149 | +``` |
| 150 | +```` |
| 151 | + |
| 152 | +### Multiple Code Tabs |
| 153 | + |
| 154 | +Consecutive code blocks create tabbed interfaces: |
| 155 | + |
| 156 | +````markdown |
| 157 | +```cjs |
| 158 | +const http = require('node:http'); |
| 159 | +``` |
| 160 | + |
| 161 | +```mjs |
| 162 | +import http from 'node:http'; |
| 163 | +``` |
| 164 | +```` |
| 165 | + |
| 166 | +When using multiple code tabs, an optional display name can be used: |
| 167 | + |
| 168 | +````markdown |
| 169 | +```cjs displayName="node:http" |
| 170 | +const http = require('node:http'); |
| 171 | +``` |
| 172 | + |
| 173 | +```mjs displayName="node:vm" |
| 174 | +import vm from 'node:vm'; |
| 175 | +``` |
| 176 | +```` |
| 177 | + |
| 178 | +## File Organization |
| 179 | + |
| 180 | +### Content Structure |
| 181 | + |
| 182 | +``` |
| 183 | +apps/site/pages/ |
| 184 | +├── en/ # English content (source) |
| 185 | +│ ├── learn/ # Learn section |
| 186 | +│ ├── blog/ # Blog posts |
| 187 | +│ ├── download/ # Download pages |
| 188 | +│ └── about/ # About pages |
| 189 | +└── {locale}/ # Translated content |
| 190 | + └── ... # Same structure as en/ |
| 191 | +``` |
| 192 | + |
| 193 | +### Asset Management |
| 194 | + |
| 195 | +- **Images**: Store in `apps/site/public/static/images/` |
| 196 | +- **Documents**: Store in `apps/site/public/static/documents/` |
| 197 | +- **Icons**: Use existing icon system or add to `@node-core/ui-components/Icons/` |
| 198 | + |
| 199 | +## Internationalization |
| 200 | + |
| 201 | +### Translation Process |
| 202 | + |
| 203 | +1. Create the English version first in `apps/site/pages/en/` |
| 204 | +2. Translators will create localized versions in `apps/site/pages/{locale}/` |
| 205 | +3. Non-translated pages automatically fall back to English content with localized navigation |
| 206 | + |
| 207 | +### Translation Guidelines |
| 208 | + |
| 209 | +- Keep file paths consistent across locales |
| 210 | +- Use the same frontmatter structure |
| 211 | +- Reference the [Translation Guidelines](./translation.md) for detailed policies |
| 212 | + |
| 213 | +## Page Types and Examples |
| 214 | + |
| 215 | +### Standard Content Page |
| 216 | + |
| 217 | +```markdown |
| 218 | +--- |
| 219 | +title: About Node.js |
| 220 | +layout: page |
| 221 | +description: Learn about the Node.js runtime and its ecosystem |
| 222 | +--- |
| 223 | + |
| 224 | +# About Node.js |
| 225 | + |
| 226 | +Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine... |
| 227 | +``` |
| 228 | + |
| 229 | +### Blog Post |
| 230 | + |
| 231 | +```markdown |
| 232 | +--- |
| 233 | +title: Node.js 20.0.0 Released |
| 234 | +layout: blog |
| 235 | +date: 2023-04-18 |
| 236 | +author: Node.js Team |
| 237 | +--- |
| 238 | + |
| 239 | +# Node.js 20.0.0 Now Available |
| 240 | + |
| 241 | +We're excited to announce the release of Node.js 20.0.0... |
| 242 | +``` |
| 243 | + |
| 244 | +### Learn Article |
| 245 | + |
| 246 | +```markdown |
| 247 | +--- |
| 248 | +title: Getting Started with Node.js |
| 249 | +layout: learn |
| 250 | +authors: nodejs-team, community-contributor |
| 251 | +--- |
| 252 | + |
| 253 | +# Getting Started with Node.js |
| 254 | + |
| 255 | +This tutorial will guide you through... |
| 256 | +``` |
| 257 | + |
| 258 | +## Validation and Testing |
| 259 | + |
| 260 | +### Before Publishing |
| 261 | + |
| 262 | +1. **Preview locally**: Use `pnpm dev` to preview your changes |
| 263 | +2. **Check formatting**: Run `pnpm format` to ensure proper formatting |
| 264 | +3. **Validate links**: Ensure all internal links work correctly |
| 265 | +4. **Test responsive design**: Check page layout on different screen sizes |
| 266 | + |
| 267 | +### Content Review |
| 268 | + |
| 269 | +- Ensure content follows our style guide |
| 270 | +- Verify technical accuracy |
| 271 | +- Check for proper grammar and spelling |
| 272 | +- Confirm accessibility of any custom elements |
| 273 | + |
| 274 | +## Advanced Features |
| 275 | + |
| 276 | +### Custom Layouts |
| 277 | + |
| 278 | +To create a custom layout: |
| 279 | + |
| 280 | +1. Add your layout component to `apps/site/layouts/` |
| 281 | +2. Update the layout mapping in `apps/site/components/withLayout.tsx` |
| 282 | +3. Document the layout purpose and usage |
| 283 | + |
| 284 | +### Dynamic Content |
| 285 | + |
| 286 | +For pages that need dynamic data: |
| 287 | + |
| 288 | +1. Use build-time data fetching in `apps/site/next-data/` |
| 289 | +2. Configure data sources in the appropriate scripts |
| 290 | +3. Access data through layout props or context |
0 commit comments