Make a branching story in Twine
ActivitiesProjects
Link story passages so a reader's choices lead to different endings in a playable HTML file.
Making a branching story in Twine starts with writing a single scene—called a passage—and wrapping each reader decision in double square brackets. Twine is a tool for interactive, nonlinear fiction where readers pick what happens next and follow the consequences, whether the piece plays like an adventure, a branching dialogue, or a role-playing scenario. You do not need to write code to finish a working story: plain passages and links are enough to carry a complete narrative from opening choice to final outcome.
Linking passages on a visual map
When you place two choices inside double brackets in your opening passage, Twine generates a new passage for each choice and draws lines and arrows between them so you can track the flow of the story at a glance. Open each new passage to write what happens after that decision, then add the next set of bracketed choices. Using `[[choice text|passage name]]` separates what the reader clicks from the destination passage's name, so a line of dialogue or an action prompt can point to a short passage title.
Shaping branches without losing control
Every decision can multiply the number of paths and passages you have to write, so a story can sprawl quickly if every choice splits into an entirely separate branch. One way to keep a project manageable is to let different choices converge back onto a single shared passage later in the story rather than carrying every branch independently to the end. At the close of the story, drafting at least two distinct endings gives different routes their own resolution, and adding a link at each ending back to the opening passage lets a reader restart and try another route.
Catching broken links early
Preview passages in a browser and click through their links as you build rather than waiting until the final scene is drafted. When a choice fails to connect, check three things first:
- whether both opening and closing double brackets are intact
- whether the link's destination matches the target passage name
- whether capitalization is consistent between the link and the passage name
Optional styling, story formats, and images
Once the passages and links work, you can keep the presentation plain or customize how the story looks. Twine uses story formats—such as SugarCube—that govern the syntax for advanced features like macros and styles, so changing story format affects how format-specific code behaves. For visual adjustments, a story stylesheet controls colors and fonts across the entire piece with CSS, while passage tags let you style individual passages differently.
Images can be placed inside passages with HTML image tags in two ways: by pointing to an external web URL or by referencing a local image file saved in the same folder as the exported story. An external URL depends on its host remaining available, while a local file has to accompany the story whenever it is moved or shared. Open the published story directly in a browser to confirm that local images load properly.
Exporting and backing up your story
Exporting with Publish to File saves the story as a single HTML file, a browser-playable page that anyone can open to play through the branches; if the story uses local images, those image files still need to be shared alongside it. You can also reopen that export in Twine later for further editing, though you will need to publish again afterward to save an updated copy. Exporting periodically as you work also serves as a backup, since browser-based drafts are saved inside the browser itself.
