Write a Generative Poem With No Technical Knowledge

Electronic Literature Oct 21, 2020

Below, I give a quick introduction to how you can create your own generative literary work, even if you have no technical knowledge. I start with some worthwhile context, but feel free to skip down to "Writing a Generative Poem" if you just want to get started writing.

I break the process down into eight steps, plus a couple side-notes for preparing your text to be shared. Other than preparing the actual content of your poem, this is a quick process. You will not be preparing your own original form. Think of this like a "How to create your own Shakespearean sonnet" guide, but for much newer forms.

Book Scale

National Novel Writing Month (NaNoWriMo) is in a couple weeks. Its premise is that anyone can write a basic draft of a short novel in a month if you set aside your perfectionist impulses and just commit to write: 50,000 words over the course of the month, averaging out to a bit over 1,666 words per day. There is no editing during this month. Just focus on getting out that rough draft.

NaNoWriMo is intended to keep the process simple and fast, kept within a limit that almost anyone can fit into each day if he or she genuinely wants to. 1,666 words per day for 30 days is still a lot for most people. What if you automated the process?

That is the premise of National Novel Generation Month (NaNoGenMo), which is also each November. Alas, this also requires effort of a different kind. You always have to be doing something to output some form of creative (or uncreative) work, though NaNoGenMo offers a much more attainable minimal goal:

It could be 50,000 repetitions of the word "meow". It could literally grab a random novel from Project Gutenberg. It doesn't matter, as long as it's 50k+ words.

To get a sense of generative novels, you can read Nick Montfort discussing his books Autopia and The Truelist here. For a different sort of possibility afforded by writing a novel generator, check out Aaron A. Reed's Subcutanean, which is printed on demand, drawing from its source in such a way that no two copies will be the same. I asked "What if you automated the process?" and the answer, it turns out, is not spending less time, but the opportunity to produce something radically different from what traditional writing allows.

Small Scale

If you want to get started on writing, you do not need to aim for a book-length work, nor do you need to limit yourself to any given month or program. You can get going whenever, but most likely, you will be working with some sort of foundation: what you know about short stories, what you know about poetry. If you know a bit about poetry, you might be thinking more specifically about, for instance, conventions of lyric poetry or of the formal constrains of a sonnet.

Like the new affordances provided by generative novels, all sorts of computer-based works are possible. During my "Literature & Hyperconnectivity" sequence, I posted about Taroko Gorge and remixes of that. As I note there,

generative poetry also provides a usable shape to writing about things such as place and experience. Montfort goes on to say in his description, "The generated text, which is produced limitlessly, is pleasing to read, perhaps, but it seems at least as enjoyable to carve into the code and shape the program to represent different experiences and ideas."

As Montfort notes in the source code, "Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies." This sort of note is relatively common (though not necessarily universal) within the electronic literature community, which is often deeply collaborative and welcoming of personal, scholarly, and creative engagement. From this, the poem is able to function as a new form for an infinite number of other topics and visions.

For today, we will be looking to a set of works even simpler to use than Taroko Gorge. Issue 5 of the online literary journal Taper, through Montfort's Bad Quarto, just came out on October 15. Submissions were limited to 2KB in size.

Writing a Generative Poem

Step 1

Open the journal:


Note two bits of text at the bottom of the page: 1) A brief introduction to the collected works, and 2) This notice:

Each of the poems in Taper #5 is licensed as free software for you to use, study, modify, and share however you like.

Then read around as you see fit. There are seventeen poems collected in total. Be aware that the nature of these texts may complicate how long a reading experience may be, such as what, if any, clear ending there is for your reading. Some offer ways of interacting with the text.

Step 2

Look at the source code of poems which interest you. (Press Ctrl/Command + U, or right-click and select "View Page Source.")

Now you can see the code loaded on the main page of the poem. Starting on line 18 for each work is a paragraph, written by the author, describing the work.

Further down is the poem itself. As I note above, these are all limited to 2KB as a matter of shared formal constraint, but yours does not have to be.

Step 3

Consider what you have seen in terms of poetic output in Step 1 and code base in Step 2. Choose a poem to work with that makes sense for you. If you are unsure, you can choose this somewhat arbitrarily, but if you have no technical knowledge, you might do better starting with a poem with a more concise code base.

A useful point of Step 2 is a chance to see that the task of editing may be simpler than you think. Todd Anderson's "Checking In," for instance, has a back-and-forth dialogic structure and a system for interactivity, but if you just want to revise the word bank, you can just find the words in the code and swap them out.

If you want a suggestion, I will be using J.R. Carpenter's "A Storm in 2K," which produces short couplets.

Step 4

You should have the source code open for the work. Again, this can be done by pressing Ctrl/Command + U, or you can right-click and select "View Page Source."

Find the text of the poem. In the case of "A Storm in 2K," this is contained entirely within line 50, starting with "var" (which is short for variable).

This is what you will be changing, so notice how it is constructed. You have "var first" and then later (you will have to scroll a long way to the right, or search with Ctrl + F) "var second." These are both followed by lists of words, separated by vertical bars (signalling "or").

If you are editing this work, you want to keep all this "var first" / "var second" framing and maintain the bars splitting the words. What you would change is the words themselves. You can remove or add splits as necessary if you want to include more or less variable line options.

Step 5

Now that you have a sense of what the work entails, you can actually go do it, but first, one quick technical bit:

You will need to copy the whole page of source code and paste it into a simple text editor, but not something like Microsoft Word. For our current needs, you can just use something like Notepad or TextEdit, but if you go on to other projects later, you mind find other programs more useful (or even necessary) for your needs.

Save a copy of this text, adding ".html" to the filename, as below:

Save this wherever you want on your computer. Now as you edit, you can just hit Save. If you are worried about messing things up, you can edit in small increments and make multiple copies of the file as you go alone.

Step 6

Prepare the text you want to be in your poem. You can write whatever you want, or work with found text.

As noted in J.R. Carpenter's description, the language is taken from ship's logs, recording one specific storm in 1870, "consulted at the National Meteorological Library and Archive at the Met Office in Exeter, UK."

You can draw from anything you want. As an experiment, do not overthink this choice, but if you plan to distribute your poem, aim for public domain writing, or your own writing (whether loose notes or traditional poems or tweets).

Remember what you noticed in Step 4. In this case, these are all couplets, so you want two create two sets of lines. If you are working with another poem's form, you will need to write according to the needs of that form, just as a sestina requires distinct considerations.

Step 7

Replace the text in the current code with your own.

Be careful not to erase too much. Missing commands, commas, quotes, etc. can make the whole thing not work. Even one misplaced character can have the whole thing come up blank. Additionally, if you yourself use an apostrophe in your text, you need to precede it with \, as in "it\'s important that you do this."

Where the text currently says:

var t=0;var first='constant rain|depression|drizzle|engines at full|hail showers|heavy squalls|mist and rain|overcast|passing showers|strong breeze

You might write:

var t=0;var first='Bad Boys for Life|Sonic the Hedgehog|Birds of Prey|Dolittle|The Invisible Man|The Call of the Wild|Onward|Tenet|The Gentlemen|Fantasy Island

(If, as just a random example, you decided you want your first lines to just be names of high-grossing movies released in 2020.)

The transition between lines in the couplet then happens here:

unsteady|violent squalls'.split('|');var second='a confused sea|a floating anchor|and thick

Do not erase that part in bold, nor the single quotes, which here appear after "squalls" and before "a confused." These contain the list of lines. Carpenter's poem lists 18 possible first lines, but if you wanted to limit your selection to 10 or 14, for example, you would simply cut out everything after your lines, up to


On the contrary, if you want to add more lines, keep filling in new lines in the format given: separate lines with "|" and no spaces.

If you have technical concerns, for a quick test, try replacing the whole list of first lines with anything you want. For instance, just write the letter "A." You should now see:

var t=0;var first='A'.split('|');var second='a confused sea|

If you have edited just this part and kept everything else there and saved it as .html, then it should open a copy of the poem where the first line is always "A," while the second lines rotate out below.

Step 7.5

In some cases, you might want to adjust a few more things.

In the case of "A Storm in 2K," the writing is all about a storm which occurred on the 6th of February, 1870. Accordingly, it lists "6 February 1870" at the top of the page. Assuming this date is irrelevant to your work, you can change or remove this. Just do a search (Ctrl + F) for that text to find it:

<div id="title"><h1>6 February 1870</h1></div>

If you delete just that part, or even just from "<h1>" to "</h1>" then the poem will still run as normal, just without that title line.

If you want to use that space for your own poem, just edit the central text, "6 February 1870" to whatever you want.

If you plan on sharing this, you will presumably want to do this for the title (line 39) and author (line 40):

An edit in three steps
An edit in three steps. The hypertext reference code (href) is useless outside of the original page.

You might also adjust the journal attribution above to be something more like "Adapted from Taper #5," but focus on getting a working text first and foremost, and secure a backup copy of that, before messing with these other details.

Step 8

Save your work.

You now have a new, electronic poem. You can open this file in your web browser to view it locally, whenever you want. You can share the file and others can do the same.

If it does not work, think back to my notices above about missing characters. Look over the work carefully. Did you accidentally delete something? Perhaps even a whole section?

Step 8.5

If you want to share this poem more readily than just passing around a file, you need somewhere you can host this.

One easy option if you already have a Gmail account is Google Sites. If you want a Google alternative, there are other free options for which you can sign up, such as CodePen.

For Google Sites, you want to open a new site, then click "Embed" in the top-right, then select the "Embed code" tab:

Copy and paste the full document in there. Then hit "Next," then "Insert." You should now see the poem running on the page. Adjust the title and anything else you want, then hit "Publish" in the top-right. Now you can share this.

For CodePen, if you have set up an account and are logged in, click "Pen" in the top-left, then paste your full document into the HTML section.

Once you "Save" on the top-right, you can share the URL. You can also get information to embed in the bottom-right.

Refer back to Step 7.5 and make any final adjustments you want to the title and author name. Keep the copyright and other attributes for the original in the source code, but you should make those further adjustments if you want to share this openly, as you typically do not want to distribute a poem under another person's name.

If you want some inspiration on how you might keep a more openly visible attribution to the author whose work you are editing, check out Taroko Gorge, which lists a history of authors on the right. <del></del> will strikeout the name, like so:

Make sure any changes you make are carried over to the online version. You might even edit directly in your browser, but you should keep a local copy as well if this is a work you care about at all.

A Sample Edit

In keeping with the sea voyage concept of the original poem (though you by no means have to), I took phrases from Samuel Taylor Coleridge's "The Rime of the Ancient Mariner" (1798).

To accompany these, I filled the second line with phrases from Chapter 4 of Coleridge's Biographia Literaria (1817), in which he discusses (among other things concerning William Wordsworth) Lyrical Ballads, the book (co-written with Wordsworth) in which Coleridge published the earlier poem.

The resulting poem: "Sadder and Wiser"


In addition to the poem itself, this post was inspired by an incredible workshop on "Assembling Weather" led by J.R. Carpenter on October 18, hosted by the Ginko Prize for Ecopoetry.

Additionally, I studied Code Poetry with J.R. Carpenter through Poetry School earlier this year.

In both, her insights into inspiration, process, pursuing textual sources, and so on far exceed this simple, technical how-to guide. I highly recommend checking out her other writing and following her to take part in any future opportunities.

Timothy Wilcox

Timothy Wilcox has a PhD in English and studies British Romanticism, imagination, computer-based writing, and the wider context of literary shifts within the digital age.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.