This skill is used to create professional Xiaohongshu note materials, including content writing, image card generation (supporting 7 style themes), and intelligent pagination rendering.
Use Cases
- When users need to create Xiaohongshu notes
- When users provide materials that need to be transformed into Xiaohongshu-style content
- When users need to generate beautifully designed image cards for publishing
- When users need a variety of style options
Workflow
Step 1: Write Xiaohongshu note content
Based on user needs and provided materials, create content that fits the Xiaohongshu style:
Title Requirements
- No more than 20 characters
- Eye-catching and curiosity-inducing
- Can use numbers, questions, and exclamation marks to enhance appeal
- Example: "5 Artifacts That Double Your Efficiency!" "Shocking! So This Is How It Should Be Done"
Body Requirements
- Use good formatting with clear paragraphs
- Add a small amount of Emoji to increase readability (1-2 per paragraph is enough)
- Use short sentences and paragraphs
- Provide SEO-friendly Tags at the end (5-10 relevant tags)
Step 2: Generate Markdown document
Note: The Markdown document generated here is used to render cards and must be generated separately. It is prohibited to directly use the note body content from the previous step.
Markdown file, the file should include:
- YAML header metadata (cover information):
---
emoji: "🚀" # 封面装饰 Emoji
title: "大标题" # 封面大标题(不超过15字)
subtitle: "副标题文案" # 封面副标题(不超过15字)
---
- Markdown text content used to render cards:
- Use
---dividers to separate the body into multiple card paragraphs - Keep the text in each section to around 200 characters
- The script will automatically detect content height and intelligently paginate
- Use
Complete example:
---
emoji: "💡"
title: "5个效率神器让工作效率翻倍"
subtitle: "对着抄作业就好了,一起变高效"
---
# 神器一:Notion 📝
> 全能型笔记工具,支持数据库、看板、日历等多种视图...
## 特色功能
- 特色一
- 特色二
---
# 神器二:Raycast ⚡
可使用代码块来增加渲染后图片的视觉丰富度
## 推荐原因
- 原因一
- 原因二
- ……
---
# 神器三:Arc 🌈
全新理念的浏览器,侧边栏标签管理...
...
#效率工具 #生产力 #Mac软件
Step 3: Render image cards
Render the Markdown document into image cards.It is recommended to use the V2 version script, which supports intelligent pagination and multiple styles.
V2 Rendering Script (Recommended)
New features in the V2 version:
- ✅ Intelligent pagination: Automatically detects content height and splits it into multiple cards when it exceeds the limit
- ✅ Multiple styles: Supports 7 preset style themes
- ✅ Word count estimation: Pre-allocates content based on word count to reduce rendering iterations
Python version:
# 基本用法
python scripts/render_xhs_v2.py <markdown_file>
# 指定输出目录
python scripts/render_xhs_v2.py <markdown_file> -o <output_directory>
# 指定样式主题
python scripts/render_xhs_v2.py <markdown_file> --style xiaohongshu
# 查看所有可用样式
python scripts/render_xhs_v2.py --list-styles
Node.js version:
# 基本用法
node scripts/render_xhs_v2.js <markdown_file>
# 指定输出目录和样式
node scripts/render_xhs_v2.js <markdown_file> -o ./output --style mint
# 查看所有可用样式
node scripts/render_xhs_v2.js --list-styles
Available Style Themes
| Style Key | Name | Description |
|---|---|---|
purple |
Purple Charm | Default style, purple-blue gradient |
xiaohongshu |
Xiaohongshu Red | Xiaohongshu brand color scheme |
mint |
Fresh Mint | Green/natural tone |
sunset |
Sunset Orange | Pink/sunset gradient |
ocean |
Deep Sea Blue | Blue-green ocean tone |
elegant |
Elegant White | Minimalist gray-white tone |
dark |
Dark mode | Dark background, high contrast |
Legacy rendering scripts (retained)
If you need to use the legacy version (automatic pagination is not supported):
# Python 版本
python scripts/render_xhs.py <markdown_file> [--output-dir <output_directory>]
# Node.js 版本
node scripts/render_xhs.js <markdown_file> [--output-dir <output_directory>]
Known issues with the legacy version: When a single card has too much content, text overflow may occur, and you need to manually use --- to separate.
Step 4: Publish the Xiaohongshu note (optional)
Use the publishing script to publish the generated images to Xiaohongshu:
python scripts/publish_xhs.py --title "笔记标题" --desc "笔记描述" --images card_1.png card_2.png cover.png
Prerequisites:
- Create
.envin the same directory and configure the Xiaohongshu Cookie:
XHS_COOKIE=your_cookie_string_here
- How to obtain the Cookie:
- Log in to Xiaohongshu in the browser (https://www.xiaohongshu.com)
- Open the developer tools (F12)
- View the Cookie in the request headers under the Network tab
Image specifications
Cover card
- Aspect ratio: 3:4 (recommended ratio for Xiaohongshu)
- Base size: 1080×1440px
- Includes: Emoji decorations, large title, subtitle
- Style: Gradient background + rounded content area (varies according to the selected theme)
Body card
- Aspect ratio: 3:4
- Base size: 1080×1440px
- Supports: Titles, paragraphs, lists, quotes, code blocks, images
- Style: White card + gradient background border (varies according to the selected theme)
- V2 version: Automatic pagination, content on a single card will not overflow
Skill resources
Script files
scripts/render_xhs.py- Python V1 rendering script (legacy)scripts/render_xhs.js- Node.js V1 rendering script (legacy)scripts/render_xhs_v2.py- Python V2 rendering script (recommended ✅)scripts/render_xhs_v2.js- Node.js V2 rendering script (recommended ✅)scripts/publish_xhs.py- Xiaohongshu publishing script
Resource files
assets/cover.html- Cover HTML template (legacy)assets/card.html- Body card HTML template (legacy)assets/styles.css- Shared stylesheet (legacy)assets/example.md- Example Markdown file
Notes
- V2 version recommended: The V2 version supports smart pagination and can automatically handle content overflow issues
- Style selection: Choose a suitable style theme according to the content style
- Markdown location: The Markdown file should be saved in the working directory, and the rendered images should also be saved in the working directory
- Content length: It is recommended that each content block separated by
---be kept within 200 characters - Cookie validity period: The Cookie for the publishing feature has an expiration limit, and it needs to be obtained again after expiration
- Publishing dependency: The publishing feature depends on the xhs library and requires installation:
pip install xhs
Smart pagination description
Smart pagination mechanism of the V2 version:
- Estimation stage: Estimate content height based on word count and element type
- Pre-rendering stage: Use Playwright to pre-render and measure the actual height
- Splitting stage: If the content exceeds the limit, intelligently split the content by paragraph/line
- Fixed output: Each card is fixed at 1080×1440px to ensure consistency
This mechanism ensures that no matter how long the content is, text overflow issues will not occur.