简体中文 / [English]


How to Configure Redirects When Using Netlify for Continuous Deployment with Hexo

This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to the original Chinese version. I am continuously working to improve the translation.

Here’s a brief description of the issue: When configuring redirects on Netlify, you need a _redirects file in the root directory of your project, with the redirect rules defined inside. See the full redirect rules here. If you’re building locally with hexo g, you can simply place this file in the public folder and push it directly to your remote repository. However, if you’re using Netlify’s build feature, you need to configure Hexo to generate the _redirects file as part of the final site output.

I searched online for a while but couldn’t find a clear solution, and the official documentation was too brief. After quite a bit of trial and error, I finally got it working—so I’m documenting it here for future reference.

Configuration steps:

  1. Place your properly formatted _redirects file into the source folder in your Hexo root directory.
  2. In the _config.yml file at the root directory, add include: _redirects. (There’s likely already an include line—just append the filename to it.)
    (Hexo ignores files starting with an underscore by default, so adding it to include forces Hexo to process it.)
  3. Still in _config.yml, add skip_render: _redirects to prevent Hexo from rendering the file—this ensures it’s copied directly to the public folder without modification.
  4. Save the changes, then run git add, commit, and push—that’s it.

This article is licensed under the CC BY-NC-SA 4.0 license.

Author: lyc8503, Article link: https://blog.lyc8503.net/en/post/hexo-config-redirect/
If this article was helpful or interesting to you, consider buy me a coffee¬_¬
Feel free to comment in English below o/