Fixing Hexo Not Generating Files
If you’re having trouble with Hexo not generating files, check for broken symbolic links in the source
directory tree:
1 | find ./ -type l -exec test ! -e {} \; -print |
It appears that if there are broken symbolic links in the source
directory tree, Hexo will not generate any new files, even if you create a new post (I haven’t tried with pages or scaffold templates). This may be by design, but I didn’t see any warnings when I went to generate so I figured I’d share my findings here.
This issue is reproducible with:
- hexo: 5.2.0
- hexo-cli: 3.1.0
- os: Darwin 19.6.0 darwin x64
- node: 12.13.1
Steps to reproduce
Start with a clean tree:
1 | $ hexo g |
No files are generated as expected.
Now create a symlink to a file. The file doesn’t have to be empty it can be any file you can symlink to and then delete. I created a file in the source/images
directory like this:
1 | $ cd source/images |
Here we can see the new file testfile.png
and the symlink pointing to it testfile-link.png
.
Let’s delete the original file and leave the broken symlink:
1 | $ rm testfile.png |
Now we can now see that symlink is dangling (broken):
1 | find ./ -type l -exec test ! -e {} \; -print |
You could also use ls
to see the broken symlink.
Next, create a new blog post using your favorite editor or via the command line:
1 | $ hexo new Testing-hexo-file-gen-issue |
At this point, we expect that running hexo g
will result in Hexo finding the new file and rendering the new post into an html page in the public
directory. However this is what happens:
1 | $ hexo g |
Uh oh, 0 files generated. There are a few ways you can fix the broken symlink. You can remove it or you can replace the file that it’s pointing to.
After fixing the symlink and trying to Hexo generate again:
1 |
|
Abracadabara! Now Hexo is generating new posts as you would expect.
Fixing Hexo Not Generating Files
https://chrisbergeron.com/2020/12/24/Fixing-Hexo-Not-Generating-Files/