Overview
The system uses two automated workflows.
- Repository → Notion When posts are pushed to the repository, a GitHub Action scans the posts directory and updates the corresponding pages in the Notion database.
- Notion → Repository Another GitHub Action periodically checks the Notion database for new or updated pages and synchronises them back into the repository as Markdown files.
This allows content to be written either locally or inside Notion while keeping the repository and database aligned.
Repository → Notion
Whenever a push occurs in the repository:
- GitHub Actions scans the local posts directory.
- Markdown files are parsed to extract metadata such as title, date, description and category.
- The workflow checks whether a corresponding page already exists in the Blog posts database.
- If the page exists, the content and metadata are updated.
- If not, a new page is created in the database. This keeps the Notion database aligned with the current state of the repository.
Notion → Repository
A second workflow runs periodically to pull content back from Notion.
During each run:
- The workflow queries the Blog posts database through the Notion API.
- It detects new or updated pages since the last sync.
- Page content is converted into Markdown.
- Files are written to the repository’s posts directory. If a post already exists locally it is updated, otherwise a new Markdown file is created.

Image handling
Images are normalised during synchronisation.
Regardless of where the image originates from:
- images uploaded to Notion
- images stored locally
- externally hosted images
All images are downloaded and stored in the website’s
assetsdirectory.
This ensures that the final website only references images hosted inside the project.
Path normalisation
When syncing posts to Notion, relative paths must be converted to absolute URLs so that they render correctly outside the repository.
For example:
../../assets/example.png
is converted to
https://your-domain/assets/example.png
This works because Astro generates a predictable asset structure.
Benefits
This setup provides several advantages:
- Posts can be edited either locally or in the Notion Blog posts database.
- The repository remains the authoritative source for the final website content.
- Images are consolidated into a single assets directory.
- Scheduled synchronisation ensures that changes in Notion are regularly pulled back into the repository.
Together these workflows create a lightweight content management system that combines the convenience of Notion with the reliability of version-controlled content.
