Translated by AI model Qwen/Qwen3-8B.
Source Language: Simplified Chinese, Target Language: english, Translation Time: 2026-05-01 02:45
.AI translation is for reference only. Accuracy is not guaranteed, please refer to the original text.
Recently I was transplanting a Typexho theme to Hexo.
Variables
The official documentation has some introduction, but it's still better to check in the VSCode debug terminal.
Method:
Press Ctrl + ` to open the terminal, click the downward arrow next to the + sign in the top right corner, and select JavaScript Debug Terminal.
Then set a breakpoint in a suitable JS file under the theme's scripts folder. For some reason, breakpoints cannot be set in EJS files.
Helper Functions
Hexo has many helper functions, and conditional tags and string processing are very handy.
Template Files
Layout (Layout)
<!doctype html>
<html>
<body>
<%- body %>
</body>
</html>
The function of <%- body %> seems to be inserting templates into different pages.
<%- body %>
<%- partial("index") %>
| Template | Page | Fallback |
|---|---|---|
index | Home Page | |
post | Post | index |
page | Page | index |
archive | Archive | index |
category | Category Archive | archive |
tag | Tag Archive | archive |
index
Home page's article list
You can use the following code to loop through and output the paginated article list
<% page.posts.each(function (post) { %>
<a href="<%= post.permalink %>" title="<%= post.title %>">
<%= post.title %>
</a>
<% }) %>
archive
Archive page
You can use the following code to loop through and output all articles list
<% site.posts.sort('date', -1).each(function(post) { %>
<a href="<%= post.permalink %>" title="<%= post.title %>">
<%= post.title %>
</a>
<% }) %>
If you enjoyed this, leave a comment~