1 Quick start
1.1 Installing Newt
Install Racket.
On macOS you will need to add /Applications/Racket\ 7.0/bin (or similar) to your PATH in order to be able to run things like racket or raco at the command line.
- Install Newt:
$ raco pkg install newt
Optional: If you want syntax highlighting for fenced code blocks:
1.2 Updating Newt
To update Newt and its dependencies:
$ raco pkg update --update-deps newt
1.3 Starting a new blog project
Creating a new blog project is 3 easy steps:
- Create a subdirectory.
$ mkdir newt-project
- Go there.
$ cd newt-project
- Tell Newt to create default files and directories.
$ raco newt --init
Creating files in /tmp/newt-project/:
/tmp/newt-project/newt.rkt
/tmp/newt-project/_src/About.md
/tmp/newt-project/_src/page-template.html
/tmp/newt-project/_src/post-template.html
/tmp/newt-project/_src/posts/2012-01-01-a-2012-blog-post.md
/tmp/newt-project/css/
/tmp/newt-project/js/
/tmp/newt-project/img/
Project ready. Try `raco newt -bp` to build and preview.
You can go ahead and build/preview this to get a feel for the default starting point:
$ raco newt -bp
Newt 0.26
Launching /usr/bin/python pipe.py
Your Web application is running at http://localhost:3000/index.html.
Stop this program at any time to terminate the Web Server.
C-c C-c
Web Server stopped.
1.3.1 Project file tree
Here is the file tree that raco newt --init creates for you and Newt expects:
project/
# Files provided by you:
newt.rkt # newt.rkt
_src/ # default; see current-source-dir in newt.rkt
page-template.html # entire page layout: Page template
post-template.html # <article> layout: Post template
index-template.html # index pages: Index template
posts/
# You’ll create these using raco newt -n <post-title>
2013-01-01-a-blog-post.md
2013-02-15-another-blog-post.md
...
# Zero or more other .md files, for non-post pages.
# May be in subdirs.
css/
bootstrap.min.css # get these files
bootstrap.min.css.map # from https://getbootstrap.com
pygments.css # style code elements from Pygments
custom.css # other styles you provide; may be empty
scribble.css
js/
jquery-3.2.1.slim.min.js # local copy of jQuery for Bootstrap
bootstrap.bundle.min.js # from https://getbootstrap.com/
img/
feed.png
favicon.ico
Here are the files created by Newt when you run raco newt -b to (re)build the blog:
project/ # default; see current-output-dir in newt.rkt
.newt/build # a cache to support minimal rebuilds
index*.html
sitemap.txt
tags/
feeds/
# Post pages are in subdirs.
# Exact layout depends on current-permalink in newt.rkt.
blog/
2013/
01/
a-blog-post-title/
index.html
...
2013/
02/
another-blog-post-title/
index.html
...
...
Although the Newt example project has copies for example purposes, for your own project you should get the official/latest Bootstrap 4 files directly from Bootstrap.
To design a Bootstrap 4 "theme", try Bootstrap Magic. Also, http://bootswatch.com/ has some ready-made themes.
For examples of "pygments.css" code highlighting styles see https://github.com/richleland/pygments-css.
1.3.2 newt.rkt
When you used raco newt --init it created a "newt.rkt" file in your project directory. If you upgrade from an older version of Newt that used a ".newtrc" file: The first time the newer version of Newt runs, it automatically creates an equivalent "newt.rkt" from your ".newtrc". Thereafter the ".newtrc" is ignored, and may be deleted.
Your "newt.rkt" lets you use simple Racket code to configure and customize your blog.
#lang newt/config | package: newt |
Furthermore, the newt/config language ensures that you define three functions that are used by Newt:
procedure
(init) → any
You can set various parameters provided by newt/params. To start, you might only need to set a few:
You may call functions provided by newt/enhance-body. You may also require and use functions provided by a third-party package.
procedure
(clean) → any
1.4 Creating blog posts
A typical workflow:
1. Create a new post with raco newt -n "My Post Title". The name of the new .md file is displayed to stdout.
2. Edit the .md file in your preferred plain text editor.
3. Regenerate your site and preview it with raco newt -bp. (You might repeat steps 2 and 3 a few times until you’re satisfied.)
4. Deploy. If you’re using GitHub Pages, you can commit and push to update your site. If you’re using some other method, you can copy or rsync the files to your static file server.