Twine turns linked passages of text into a playable web game, and it is perfect for horror. Every choice is a door the player does not have to open. Write a passage, add [[a link]], and Twine draws the arrow. This guide covers links, variables, sanity meters, jump scares, timers, creepy styling and publishing, with code you can copy straight into your own story.
An eight-passage Twine horror story. Your great-aunt Edith has left you her house, and something in it has been waiting. Every passage shows its real Harlowe source on the right, and the Variables tab tracks what you carry and how much sanity you have left. The rooms are tagged with effects from the Effects lab below: the parlour is candle, the attic is storm, the cellar is blood. There are five endings.
Twine runs in the browser at twinery.org or as a desktop app. The desktop app saves stories as files in a Documents/Twine folder, which is safer for coursework.
Go to twinery.org. Choose Use it online or download the app for Windows, macOS or Linux.
In the Library, click + New and name it. You land on the story map with one passage, marked with a green rocket as the start.
Open Story › Details. Leave the story format on Harlowe 3 for this guide. The format decides which code syntax works.
Double-click a passage to edit. Type [[Open the cellar door]] and a new passage with that name appears on the map, joined by an arrow.
Build › Test plays the story with a debug panel showing every variable. Build › Play shows the player's view.
Build › Publish to File produces one .html file that runs in any browser. Upload it to itch.io as an HTML game or hand it in as is.
Paste any snippet into a passage. Macros look like (name: value), hooks are the square brackets that follow them, and variables start with $. The Horror filter collects the scare techniques.
Every Harlowe story is plain HTML using custom tags such as tw-story, tw-passage and tw-link, so ordinary CSS restyles it. Paste CSS into Story › Stylesheet. Pick one of eight complete themes, then edit the code on the left and watch the preview change.
Hover over the words in the dust. Every theme hides them until the mouse finds them.
| Selector | What it styles |
|---|---|
tw-story | The whole page: background, base font, text colour. |
tw-passage | The block of text for the current passage. |
tw-link, .enchantment-link | Passage links, and links created by (link:) style macros. |
tw-link:hover | A link under the mouse pointer. |
tw-sidebar | The undo and redo arrows. display: none hides them, so players cannot undo their way out. |
tw-hook[name="dust"] | One named hook, written |dust>[ ... ] in the passage. |
tw-story[tags~="haunted"] | Any passage that carries the tag haunted (Harlowe 3.2 and later). |
.glitch | Your own class, used in a passage as <span class="glitch">...</span>. |
Twenty-three horror effects, each running live. Every one is plain CSS for Story › Stylesheet. Most switch on with a passage tag, so the effect only appears where you choose. Some need a line of HTML in the passage, and the torch needs a few lines of Story JavaScript.
The grey chips on each card show which element the effect draws on. Two effects that use the same pseudo-element, such as tw-story::before, cannot run on the same passage because the second rule replaces the first. To combine them, move one effect onto a free slot like tw-passage::after, or give a passage several tags, for example candle heartbeat, where the slots differ.
Twine ships with several story formats. Harlowe is the default and the friendliest to start with. SugarCube is closer to JavaScript and popular for bigger games. The same idea, written both ways:
| Task | Harlowe 3 | SugarCube 2 |
|---|
The mistakes that haunt almost everyone once.
[[cellar]] and [[Cellar]] point at two different passages.->." into “smart quotes”. Retype them in Twine.to, never =.(set: $x to 1) works. (set: $x = 1) is an error.(set: not ( set :, and keep the hook touching: (if: $x)[yes]._item only lives in the current passage. Use $item to keep it.images/cellar.jpg only work once the published HTML sits next to the images folder.Each one adds a single new technique on top of the last.
Five passages, one choice, two endings: one where the player escapes and one where they do not. Links only.
The exit only appears once the player holds both the key and the torch. Use (a:) and contains.
A header passage that draws the player's sanity on every page and turns the text red when it drops to 2 or below.
A 60 second (live:) countdown. At zero, (go-to:) a pitch-black ending passage.
Tag the haunted passages haunted and give them a completely different look from the ordinary ones.
A passage that changes every time it is visited using visits, plus whispers that rewrite themselves every few seconds with (live:) and (either:).