Hexo Blog Building: Syncing Notion Content to Hexo Blog via Elog
Introduction
This article is part of the Hexo blog setup guide series version 1.1, focusing on the process of synchronizing Notion content to a Hexo blog using Elog. For a comprehensive overview of the entire blog setup series, please refer to the detailed guide: Hexo Blog Building Guide: Systematic Solutions and Detailed Construction Process.
Overall Process
- The process is as follows:
Explanation:
- The process consists of three main stages: preparation, Notion configuration, and local Hexo blog configuration.
- The Notion configuration involves creating a Notion database and enabling access to it via a token for content updates.
- The local Hexo blog configuration focuses on initializing Elog and establishing the connection between Notion and Hexo.
Preparation
- Prepare the Hexo blog by following this reference: Hexo Blog Building: Setting Up a Local Blog, Deploying to GitHub Pages and Cloudflare Pages.
- Register for a Notion account.
- Install Elog globally:
1 | Installation |
Notion Configuration
Create an Integration Token
Refer to the official Notion documentation: https://developers.notion.com/docs/create-a-notion-integration#create-your-integration-in-notion.
Access the integrations section here: https://www.notion.so/profile/integrations.
- The process is as follows:
Duplicate the Created Notion Database
You can refer to the elog-hexo-template to create a copy of the database or add necessary properties to an existing Notion database.
Connect the Database to the Newly Created Integration
- Click on the “…” in the upper right corner, select “Connections,” then choose the previously set token (for example: hexo-elog-token-en), and click “Confirm.” This will successfully connect the current database with the token.
Record Token and Database ID
(1)Record Token
For example:
(2)Record Database ID
For example:
Local Hexo Blog Configuration
Initialize Elog in the Hexo Project
1 | Initialize Elog configuration file |
Configure Token and Database ID
In elog.env
, configure your token and database ID.
Configure Synchronization Rules in elog.config.js
In elog.config.js
, set up synchronization rules:
1 | module.exports = { |
Execute Synchronization
Run the synchronization command:
1 | npx @elog/cli sync -e .elog.env |
Synchronization Results
If successful, you will see a message indicating that synchronization is complete:
1 | (base) $ npx @elog/cli sync -e .elog.env |
Preview the Blog
- Preview your blog locally to verify that Notion content has been synchronized to your Hexo blog.
- If it meets your requirements, you can proceed with online deployment; if there are issues, make targeted adjustments.
Daily Operations
Optimizing Notion Content Synchronization
- To synchronize line breaks within cells, use Markdown format
<br>
. Direct line breaks in Notion may cause content to jump to a new line instead of staying within the cell. - For links with titles, first insert the link in Notion, then edit it to manually define the link’s title.
- For images with titles, insert an image in Notion and edit its caption to define its title manually.
Management Methods for Notion + Hexo
- Use scattered time to record in Notion and regularly synchronize in batches using Elog for enhanced efficiency.
Important Notes
- If you modify titles in Notion, it will generate a new Markdown file upon synchronization with Hexo. Be sure to clean up any old Markdown files promptly.
Conclusion
By following these configurations, you can successfully synchronize Notion content quickly to your Hexo blog. This process not only enhances content management efficiency but also adds flexibility and convenience to your blogging experience.
As we use this setup in practice, we will continually refine synchronization details to meet various needs and scenarios. Stay tuned for updates as we regularly publish new tips and best practices to help you better utilize Notion and Hexo for content management.