Menu

Getting started

Step 2 of 2

Writing guides

“Everything you can use in a guide page, with the Markdown that makes it.”

View .md

This page is a cheat sheet for writing guides here. Every feature below shows the Markdown that produces it.

Topics, parts and pages#

Bytes are organized in three levels. Every folder is a level, and every folder has an _index.md:

text
content/bytes/
├── _index.md                        ← the Bytes landing page
└── http/                            ← a topic: "How HTTP works"
    ├── _index.md                    ← topic title, intro text, order
    ├── basics/                      ← a part: "The basics"
    │   ├── _index.md
    │   ├── what-is-http.md          ← a page (step 1)
    │   ├── anatomy-of-a-url.md      ← step 2
    │   └── request-response-cycle/  ← a page with images gets its own folder
    │       ├── index.md
    │       └── cycle.svg
    └── requests/                    ← next part
        ├── _index.md
        └── http-methods.md
  • A topic gets a card on the Bytes page and its own sidebar.
  • A part groups pages under a heading in the sidebar.
  • Pages are numbered as steps (“Step 3 of 9”) in reading order, with Previous/Next links that run through the whole topic.

You can nest parts inside parts, and a topic can also hold pages directly without any parts.

Order with weight#

Every _index.md and page has a weight. Lower comes first:

content/bytes/http/requests/_index.mdyaml
1---
2title: "Requests"
3description: "What the client sends: methods, headers and data."
4weight: 2
5---
content/bytes/http/requests/http-methods.mdyaml
1---
2title: "HTTP methods"
3description: "Shown under the title, in the outline and in search results."
4weight: 1
5---

Adding things#

bash
hugo new content bytes/http/requests/cookies.md

To start a new topic, create content/bytes/<topic>/_index.md with a title, description, weight and an intro. Give it a color (indigo, teal, amber, violet, rose or sky) and an icon: they style its animated cover, its cards and its share images. See brand/README.md for which color fits which kind of topic. Its landing page shows the intro, a Start reading button and a numbered outline of every page.

Linking between pages#

Use relative links to the folder of the page:

markdown
See [status codes](../../responses/status-codes/).

Code blocks#

Filename tab#

Add a title after the language:

markdown
1```js {title="src/app.js"}
2console.log("hi")
3```
src/app.jsjs
const app = createApp();
app.listen(3000, () => console.log("listening on :3000"));

Highlighting lines#

Use hl_lines to draw attention to specific lines:

markdown
```go {hl_lines="6-7"}
go
 1package main
 2
 3import "fmt"
 4
 5func main() {
 6	total := 0
 7	for i := 1; i <= 10; i++ {
 8		total += i
 9	}
10	fmt.Println(total)
11}

Line numbers#

Code longer than two lines gets line numbers automatically. Shell snippets don’t. Turn them off with {lineNos=false} or start from another number with {linenostart=40}.

bash
hugo new content bytes/http/requests/cookies.md
./dev.sh

Callouts#

Use GitHub-style alerts for side notes:

markdown
> [!NOTE]
> Useful information the reader should notice.

Note

Useful information the reader should notice, even when skimming.

Tip

A better or easier way to do something.

Important

Something the reader needs to know to succeed.

Warning

Something that can go wrong if they’re not careful.

Caution

Something that can break things or lose data.

Custom title

Write your own title after the type.

Images#

Put the image in the page’s folder and reference it by name. The text in quotes becomes the caption. Click an image to zoom in.

markdown
![Request flow from browser to server](diagram.svg "A request travels from the browser to the server and back")
Request flow from browser to server
A request travels from the browser to the server and back

Tables#

SyntaxResult
**bold**bold
*italic*italic
`code`code
[link](url)link

Glossary terms#

Wrap a term to give it a hover card with its short definition. The definitions live in data/glossary.yaml, and every term also gets an entry on the Glossary page, with the bytes that use it.

markdown
The browser asks a {{< g "dns" />}} resolver for the address.
Computers connect to {{< g "ip-address" >}}IP addresses{{< /g >}}, not names.

The browser asks a DNS resolver for the address. Computers connect to IP addresses, not names.

To add a term, add an entry to data/glossary.yaml with a term, a one- or two-sentence def and the page that explains it best in see. A typo in a term’s id stops the build with a clear message, so broken terms never go live.

Margin notes#

For a fun fact or an aside that would interrupt the sentence:

markdown
HTTP has a status code for teapots.{{< note >}}`418 I'm a teapot`, from a 1998 April Fools' joke.{{< /note >}}

HTTP has a status code for teapots.418 I'm a teapot, from a 1998 April Fools’ joke. It shows as a small number after the sentence: hover it, or tap it on a phone, and the note opens in a little card. It never takes extra space on the page.

Byte check#

A short quiz at the end of a byte. Getting every answer right commits the byte to the reader’s learning path, so put two or three questions in the front matter of every byte:

content/bytes/http/requests/http-methods.mdyaml
1---
2title: "HTTP methods"
3check:
4  - q: "Which method should **never** change data on the server?"
5    options: ["`GET`", "`POST`", "`DELETE`"]
6    answer: 0             # the right option, counting from 0
7    why: "`GET` is *safe*, so browsers and crawlers may send it freely."
8---

Bytes without a check end with a Commit this byte button instead. It unlocks once the reader has spent about a third of the reading time on the page and reached the end, so a quick scroll doesn’t count. Either way, a committed byte can be undone with git reset.

Interactive examples#

Two “Try it” widgets you can drop into any page:

markdown
1{{< url-explorer >}}
2{{< url-explorer "https://example.com/search?q=http#results" >}}
3
4{{< http-builder >}}
5{{< http-builder method="POST" path="/todos" >}}
  • url-explorer takes a URL apart, colors each part and shows the request the server actually receives.
  • http-builder sends requests to a pretend to-do API that runs in the reader’s browser, and shows the raw request and response.

Byte cards#

Give a topic up to five takeaways (each under ~100 characters). The topic page then shows a shareable image card with a download button:

content/bytes/http/_index.mdyaml
1takeaways:
2  - "HTTP is plain text: a client sends a request, the server sends one response."
3  - "Status codes by first digit: 2xx worked, 3xx look elsewhere, 4xx your mistake, 5xx theirs."

Every page also gets its own link preview image automatically, with its title on the AminBytes background. To change their design, edit brand/src/og.py and run python3 brand/src/og.py.

this byte

staging

Read it through, then commit this byte to your learning path.

$ git add writing-docs.md

Staging while you read…

Search posts and bytes

Optional account

Keep your progress everywhere

Everything on AminBytes is free to read, with or without an account. Sign in only if you want your commits, streak and merged topics saved, on every device.

or

We keep only your name, avatar and which bytes you finished, and you can delete it all anytime. Privacy