Notion
Database
Duplicate the template in your workspace :
API integration
Go to your integrations in Notion and create a new integration, and name it
Choose the workspace in which you have duplicate the template
Set it capabilities like above, indeed the integration only need read
access
Get the API key and save it, you will need it later
Allow integration to access your database
Go to your notion’s blog database and add your integration to it
GitHub
Create a new repository
Create a new repository using this template
When you choose the repository name you have two options :
-
if you choose
<github_username>.github.io
your blog’s URL will behttps://<github_username>.github.io
-
if you choose anything else your blog’s URL will be
https://<github_username>.github.io/<repository_name>
or you will be able to set your own domain name later if you have one
Edit Hugo config file and GitHub Actions file
Depending on your blog’s domain, edit the config.yml
file on the root of your repository, change baseURL
at line 1
In the previous step, if you use URL like https://<github_username>.github.io/<repository_name>
you need to edit wrapper parameters in .github/workflows/build.yml
and change /notion-ghpages
with /<repository_name>
or delete it if you use your own domain name or if you use URL like https://<github_username>.github.io
If you want to use your own domain name, add cname: <your_domain>
at the end of .github/workflows/build.yml
like above :
Add GitHub Actions secrets
In the settings of your repository, you need to add two variables to allow GitHub Actions to fetch your posts on Notion
-
NOTION_API_KEY
: your Notion integration API key -
NOTION_DB_ID
: ID of your Notion’s blog database like that :
GitHub Actions permissions access
You need to give write access to GitHub Actions to allow it to create a branch for your blog
Build your blog
When you want to build your blog or just publish an update you need to the following :
Deploy your blog
If you use your own domain name you need to set it
And add these A
entries in your DNS record :
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
You can find further information here
Troubleshooting
-
GitHub uses CDN caching for Pages, so when you made an update it can take about 10 minutes to appear on your blog. As workaround you can clear your browser’s cache then refresh your page.
-
If the build fail, it can be due to unsupported Notion block on the wrapper, so you can open an issue here or it can be due to a missing properties on your Notion database, so you can check the changelog file here to update it.