Hexo: Can't make skip_render to work

Created on 11 Oct 2016  ยท  6Comments  ยท  Source: hexojs/hexo

Environment Info

Node version(node -v)

v6.5.0

Your site _config.yml

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: ~
subtitle: ~
author: ~
language: en-GB
timezone: Europe/London

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://oncletom.io/talks
root: /talks/
permalink: :year/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: ""
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
  - "**/*/{slides,images}/*"

# Writing
new_post_name: :year/:title.md # File name of new posts
default_layout: talk
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 1
render_drafts: true
post_asset_folder: true
relative_link: false
future: true
highlight:
  enable: false
  line_number: true
  auto_detect: false
  tab_replace:

# Category & Tag
default_category: uncategorized

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 0

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: ../node_modules/hexo-theme
layout: talks

nunjucks:
  autoescape: true
  throwOnUndefined: false
  watch: false


archive_generator:
  per_page: 0
  yearly: false
  monthly: false
  daily: false

Plugin version(npm ls --depth 0)

[email protected] /Users/thomaspa/Projects/talks
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected]

For question

I have a structure like this:

source
โ””โ”€โ”€ _posts
    โ””โ”€โ”€ :year
        โ”œโ”€โ”€ :post-asset-folder
        โ”‚ย ย  โ”œโ”€โ”€ _outline.md
        โ”‚ย ย  โ”œโ”€โ”€ images
        โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ **.png
        โ”‚ย ย  โ””โ”€โ”€ slides
        โ”‚ย ย      โ”œโ”€โ”€ slide01.md
        โ”‚ย ย      โ”œโ”€โ”€ slide02.md
        โ”‚ย ย      โ”œโ”€โ”€ slide03.md
        โ”‚ย ย      โ”œโ”€โ”€ slide04.md
        โ”‚ย ย      โ””โ”€โ”€ slide05.md
        โ””โ”€โ”€ :post.md

I can't manage to get all the .md files in the ./slides to be excluded.
I have tried various combinations of skip_render setting but no luck so far :-(

Any idea or suggestion? Thanks :-)

wontfix

Most helpful comment

Deleting db.json in the root folder solved the problem for me

All 6 comments

Or maybe to be more precise: I don't want the files matching the pattern to be Processed, I am just happy to see them copied without being processed by markdown to be rendered into html.

I think this is a bug. I tried using skip_render to stop the rendering of hello-world.md in a test blog and could provide no value in the config that resulted in it not getting rendered. The config values I tried:

hello-world.md
_posts/hello-world.md
"hello-world.md"
[hello-world.md]
["hello-world.md"]
hello-world
hello-world.*

These were tried both with dynamic serving and with generate-ing and then serving the static files.

I also tried putting skip_render: true in the front matter. Conclusion: I have no idea what skip_render expects to do. Or maybe I just don't know how to use it properly.


Interestingly, I tried renaming the post to hello-world.html to see if it would just print the raw content and it did with the exception of the _code_ elements. Apparently even html files get processed for code tags?

Another interesting thing is that when skip_render: hello-world.md is in the config file, it _is_ registered in the processor as not renderable, yet is still rendered.... as witnessed by running the following in the base directory with hello-world.md and test-1.md both posts in source/_posts:

$ node
> var Hexo = require('hexo')
undefined
> var hexo = new Hexo()
undefined
> hexo.init()
...(omitted)
> hexo.config.skip_render
'hello-world.md'
> hexo.source.processors[0].pattern.match('hello-world.md')
{ renderable: false }
> hexo.source.processors[0].pattern.match('test-1.md')
{ renderable: true }

It would appear these variables aren't being checked?

@oncletom, if you're trying to insert raw content of files into a post, I wrote a plugin called hexo-include to do just that.

Deleting db.json in the root folder solved the problem for me

@wilddeer I have tried deleting db.json after updating the rules, checking them against http://www.globtester.com/ and sadly it changed nothingโ€ฆ The files matching the skip_render still appear in the Processed: <path-to-file> debug output :-(

Well I guess it is displayed as Processed because if it considered as renderable, it is treated as a Page otherwise as an Asset.

So I guess it works but for some reasons, because I try to exclude markdown files, they are still listed in hexo.posts โ€ฆ :-(

you are right!

Was this page helpful?
0 / 5 - 0 ratings