benbalter / jekyll-relative-links

A Jekyll plugin to convert relative links to markdown files to their rendered equivalents
MIT License
141 stars 37 forks source link

YAML frontmatter field named `excerpt:` breaks jekyll-relative-links #91

Open p3palazzo opened 1 year ago

p3palazzo commented 1 year ago

Describe the bug

When a file has a field with the key excerpt: in its YAML frontmatter, jekyll-relative-links v0.7.0 will cause an exception that prevents the website from rendering:

Expand error log ``` Configuration file: ~/Documents/jekyll-test/_config.yml Source: ~/Documents/jekyll-test Destination: ~/Documents/jekyll-test/_site Incremental build: disabled. Enable with --incremental Generating... Jekyll Feed: Generating feed for posts ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:93: warning: Jekyll::Excerpt#yaml_file? at /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/forwardable.rb:159 forwarding to private method Jekyll::Page#yaml_file? Liquid Exception: undefined method `yaml_file?' for # in ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/minima-2.5.1/_layouts/default.html ------------------------------------------------ Jekyll 4.3.2 Please append `--trace` to the `build` command for any additional information or backtrace. ------------------------------------------------ /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/forwardable.rb:238:in `yaml_file?': undefined method `yaml_file?' for # (NoMethodError) from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:93:in `render_with_liquid?' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:78:in `render_document' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:63:in `run' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:83:in `output' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:70:in `to_s' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/page.rb:193:in `excerpt' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:117:in `block in to_liquid' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:116:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:116:in `each_with_object' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:116:in `to_liquid' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:499:in `block in each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:498:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:498:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:220:in `map' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:220:in `map' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/strainer.rb:56:in `invoke' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb:86:in `invoke' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:84:in `block in render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `inject' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/assign.rb:26:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:91:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:206:in `block in render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:240:in `with_profiling' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:205:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:218:in `render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:36:in `render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/inclusion.rb:16:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/tags/include.rb:208:in `block in render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb:123:in `stack' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/tags/include.rb:206:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:91:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:206:in `block in render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:240:in `with_profiling' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:205:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:218:in `render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:36:in `render!' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:129:in `render_liquid' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:192:in `render_layout' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:161:in `place_in_layouts' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:93:in `render_document' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:63:in `run' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:572:in `render_regenerated' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:557:in `block (2 levels) in render_docs' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:556:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:556:in `block in render_docs' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:555:in `each_value' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:555:in `render_docs' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:210:in `render' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:80:in `process' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:28:in `process_site' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:65:in `build' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:36:in `process' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/exe/jekyll:15:in `' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/bin/jekyll:25:in `load' from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/bin/jekyll:25:in `' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli.rb:491:in `exec' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli.rb:28:in `start' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/bundler-2.4.6/exe/bundle:45:in `block in ' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors' from /usr/local/Cellar/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/bundler-2.4.6/exe/bundle:33:in `' from /usr/local/opt/ruby/bin/bundle:25:in `load' from /usr/local/opt/ruby/bin/bundle:25:in `
' ```

Steps to reproduce the behavior

  1. Setup the default Jekyll website and add gem "jekyll-relative-links", "0.7.0" to the Gemfile
  2. Add a field named excerpt: with any value to the YAML frontmatter of a Markdown file in the repo.
  3. jekyll build
  4. See error log above

Expected behavior

Jekyll-relative-links should not interfere with well-formed YAML frontmatter.

Attached test repo

jekyll-test.zip

Additional context

monarchwadia commented 9 months ago

Yeah, I uninstalled jekyll-relative-links because of this issue, since jekyll-seo-tag which uses excerpt is more important for my use case.