한국어 | English | 日本語
Senior Web Application Developer (8.8+ years)
Tech & Dev
engineering
Focusing on web frontend and backend development

How to Debug Hexo in VSCode

If you've ever felt frustrated wanting to customize your Hexo blog theme but struggled to see how your changes reflected, this guide is for you. Learn how to leverage VSCode's debugging capabilities to analyze .jsx code in modern themes like Icarus, troubleshoot errors, and perfect your custom theme with this practical guide.
Understand the core structure of Hexo themes, including style files (.styl) and rendering logic (.jsx). This guide provides specific instructions on how to set up local server debugging in VSCode using launch.json, enabling you to visually track complex theme customization processes and work more efficiently.

Customizing Hexo Themes

Even after choosing a theme for Hexo, you might find parts you want to modify. Although themes often provide YAML-based configurations, if you desire more granular control, you’ll need to directly edit the theme’s code. When I started my self-hosted Hexo blog, the Icarus theme I selected was broadly divided into two types of code:

Customizing .styl Files

Settings such as width, height, font size, and color are configured in the .styl code. Analyze the CSS settings of each element on your browser’s page. If a corresponding setting exists, modify its value. If not, Bulma’s default settings will be used, so you’ll need to add your desired settings to override them.

Customizing .styl files

Customizing .jsx Files

The rendering of articles and widgets on the page is configured in .jsx code. To understand how content is rendered on the screen and whether your modified code is working correctly, debugging is essential. Since I manage my Hexo blog using VSCode, I debug Hexo within VSCode.

Customizing .jsx files

Debugging Setup

VSCode debugging settings can be configured via the “Add Configuration…” option in the debug list to the right of “RUN” in the Debug view.

Add Configuration on VSCode

Selecting “Add Configuration…” will create a .vscode directory and a launch.json file within your current project directory. It will then open this file and display a list of configuration options you can add, as shown below.

Add Configuration's Options on VSCode

From the list, select “Node.js: Launch Program” to add a configuration.

Node.js: Launch Program

Modify it as follows:

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Hexo Debugging",
            "program": "${workspaceFolder}/node_modules/hexo-cli/bin/hexo",
            "args": [
                "server"
            ]
        }
    ]
}

Since this is for debugging hexo server running locally, the target program is hexo-cli’s bin/hexo, and you can see server in the args. Now you can enjoy creating your custom theme while debugging. Furthermore, you might even share your unique theme with others or contribute extended functionalities as a Git contributor to existing themes.



How to Debug Hexo in VSCode
Author
Aaron
Posted on
Licensed Under
CC BY-NC-SA 4.0
CC BY-NC-SA 4.0
More in this category
Recent posts
The Erosion of Conversational Muscle and Communication Styles by LLM Filters
In an era where LLM tools, which filter out conversational impoliteness and deliver refined responses, have become commonplace, are we truly engaging in more thoughtful conversations? This article examines the phenomenon of conversational ability, which should be honed through countless failures in real-time communication, degenerating due to reliance on external tools. It further explores the potential societal anxieties and shifts in generational behavioral patterns that this trend may bring.
Optimal Timing and Strategy for Salary Negotiation with Senior Candidates
Salary negotiation is more than just an exchange of figures; it's a strategic dance of psychological timing. This analysis explores why engaging in a gradual negotiation process from the initial stages of recruitment, rather than waiting until after a final offer (when candidates tend to adopt a more calculative stance), proves more efficient for companies and fosters a more honest sharing of resources.
The Limits of the Rule of Law and Human Diversity
The belief that all human actions can be regulated by a single legal system may be an act of hubris. This article offers a sharp analysis of the paradox of the rule of law faced by humanity, which, having escaped the hierarchical controls of the Middle Ages, has now embraced infinite modern freedom. It further examines the deepening social coercion and the demonization of others that arise under the guise of diversity.
토스트 예시 메세지