Setting up
Observable Notebook Kit
in order to develop notebooks into websites locally
Create your First Project Folder and Set Up the Notebook Kit
The desktop app is a notebook editor that creates, edits and saves HTML files. (These files have .html as their extension but have a special format.)
You will be editing these files inside folders that are organized to use the Observable Notebook Kit. Once set up, the Kit allows you to turn your notebooks into a publishable web site that you can view locally at first and then publicly.
For installations and configurations, you are going to need a plain text editor. If you know what I’m talking about and of you have one, fine. If not, and you are using a Mac, download and install CotEditor. If you’re on a PC, I’m afraid I leave you to your own devices.
- In whatever way is most comfortable for you (and best organized) create a folder called something appropriate like:
ObservableNotebooks. - Inside this folder make another folder called
nbks. This is where you will create and store your notebook files. - Open the Observable Desktop app and then edit the
Untitleddefault document that appears. Edit the title and create a few more MarkDown,md, cells with some text in them. - Select
File —> Save As...to save what you’ve done, using the nameindex.html, inside thenbksfolder of your project folder. Thisindex.htmlfile is special and we’ll explain why later. - Now use your Terminal program and its Command Line Interface (CLI) to navigate to your
ObservableNotebooksproject folder. If you haven’t done this before, we’ll do this together in workshop, and/or ask questions. - Now, if you’ve never done so before, you will need to install
node.jsvia a package manager callednpm(Node Package Manager). Go to step 8 if you already havenpminstalled, otherwise: - Download the installer for
node.jsthat is best for your computer. If you have a Mac download from here. Follow instructions for installation. Verify the installation with commands that show the installed versions of these packages. At the terminal, type, on separate lines:
node -v
npm -v
- Next, at the Terminal, type:
npm add @observablehq/notebook-kit
- Now open up your plain text editor (see above). Find and edit the file
package.jsonwhich has been created by the previous step inside yourObservableNotebooksfolder. You can just replace the entire contents of the file with the following (it’s thescriptspart that needs adding):
{
"dependencies": {
"@observablehq/notebook-kit": "^2.0"
},
"scripts": {
"preview": "notebooks preview --root nbks",
"build": "notebooks build --root nbks --out ../docs -- *.html"
}
}
- Finally, for now, in your terminal, type:
npm run preview
Then type h and hit return. Read and explore what is displayed.