- Command line arguments
- Run in Docker
- Example - generate a static website from Notion
- Example - serve a website from a Notion space (with HTTPS!)
- How to get an access token
- License
Generates a static website from Notion and watches for changes.
notion2html generate -o <output_dir> -t <access_token> [-f|--force]
Here:
-o <output_dir>
- path to output directory-t <access_token>
- access token for Notion-f
,--force
- disable incremental update
notion2html watch -o <output_dir> -t <access_token> [-p <period>]
Here:
-o <output_dir>
- path to output directory-t <access_token>
- access token for Notion-p <period>
- watch timer period (by default -1h
)
Use the following docker compose file as a reference:
version: '2.4'
services:
notion2html:
image: ghcr.io/kapitanov/notion2html:latest
environment:
# Access token for Notion (required)
NOTION_API_TOKEN: '<access_token>'
# Watch timer period (optional, '1h' by default)
TIMER_PERIOD: '1h'
# Path to output directory (optional, '/out' by default)
OUTPUT_DIR: '/out'
volumes:
# Output directory mapping
- ./out:/out
First, you would need an access token for Notion.
Then, you can run the following command:
docker run -t --rm -v $(pwd):/mnt ghcr.io/kapitanov/notion2html:latest generate --token "<access_token>" --output /mnt --force
Note
"<1access_token>"
above - you should put your access token there.
This command will export all pages from Notion to the current directory as a single static website.
First, you would need an access token for Notion. Second, you would need a domain name configured for your server.
Then, you can run the following command (on your server):
$ ACCESS_TOKEN="<access_token>" DOMAIN="<domain>" cat << EOF > docker-compose.yaml
services:
notion2html:
image: ghcr.io/kapitanov/notion2html:latest
restart: always
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "1"
environment:
NOTION_API_TOKEN: '$ACCESS_TOKEN'
TIMER_PERIOD: '1h'
OUTPUT_DIR: '/out'
volumes:
- ./www:/out
nginx:
image: steveltn/https-portal:latest
ports:
- 80:80
- 443:443
restart: always
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "1"
volumes:
- ./out:/usr/share/nginx/html
environment:
DOMAINS: '$DOMAIN'
volumes:
- ./https-portal-data:/var/lib/https-portal
- ./www:/var/www/vhosts/$DOMAIN
EOF
$ docker-compose up -d
Note
ACCESS_TOKEN="<access_token>"
andDOMAIN="<domain>"
above - you should put your access token and domain name there.
This command will export all pages from Notion to the www
directory as a single static website and serve it with HTTPS.
HTTPS will be powered by an awesome https-portal,
with automatic LetsEncrypt certificates.
- Visit notion.so/my-integrations and click "New integration" button.
- Enter a name for your integration (you will need it to connect this integration to your page).
- Unckeck everything except "Read content".
- Click "Submit" button.
- On the next page, you will see a "Internal Integration Token" field - that is the access token.
- Now, open a root Notion page and click "..." button in the top right corner.
- CLick on "Add connection" menu item and add your integration (yoi might need to use search by name here).