How can I tell Hexo to ignore the file when creating messages?

In source/_posts

I have a directory post.md

and post/

to store assets for post.md

.

As post/

I have js/main.min.js

, which is used post.md

for illustration.

Hexo picks up main.min.js

and creates a post for him. How can I get around this?

+3


source to share


3 answers


The only solution I found was to include the directory for the post in source

ie source/post

(outside / next to source/_posts

).

Then you can put your assets and reference them in the md file for example.

<script src="/post/js/main.min.js"></script>



Btw, I tried using _config.yml

skip_render

:

skip_render:
  - "**/*.js"
  - "*/*.js"
  - "_posts/post/js/main.min.js"

      

and other options, but they all result in what main.min.js

appears as a message.

+4


source


I had a similar problem, but it was with json files. In my case, all json files will be turned into pages and I don't want them to be. So, I ended up creating a file extend.js

and placing it inside the scripts folder in my theme. Then I included this bit of code.

hexo.extend.filter.register('after_init', function () {
  // Remove json files being inserted to db.json -> Pages

  var listSync = hexo.extend.renderer.list(true),
      listAsync = hexo.extend.renderer.list();

  delete listSync.json;
  delete listAsync.json;
});

      



Possible objects that you can delete are htm, html, css, js, json, swig, yml, yaml

. Hope it helps.

+4


source


I think Hexo will ignore any underscore file, so you need to rename your file .js

to_main.min.js

+1


source







All Articles