Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need to config Related-Popular-Posts both in _config.yml and _config.next.yml #870

Open
3 tasks done
erispyu opened this issue Jan 3, 2025 · 4 comments
Open
3 tasks done
Labels
Bug Something isn't working Need More Info Further information is requested

Comments

@erispyu
Copy link

erispyu commented Jan 3, 2025

Issue Checklist

Expected behavior

Only config in _config.next.yml, according to the theme's doc: Related-Popular-Posts

Actual behavior

When tried to customize the threshold & detailed weight config of the hexo-related-post plugin, I found that I need to config _config.yml and _config.next.yml both.

I've tried debug in WebStorm, when the plugin calculated the related posts, it would read from _config.yml, but when the theme rendered the pages, it would then read from _config.next.yml.

Steps to reproduce the behavior

  1. Generate more than 5 posts.
  2. Only config in _config.yml, use the following config:
related_posts:
  enable: true
  icon: fa fa-signs-post
  filter_threshold: 0.001
  related_count: 5
  weight:
    title: 0.1
    author: 2
    description: 0.08
    keywords: 0.05
    tags: 0.1
    categories: 0.05
    text: 1

This sample config set a very low filter_threshold (can set to 0 as well), but very high weight, so the expected result is that each post should have 5 related posts.

And we can see the plugin do calculate the related posts:

Debug Result:
截屏2025-01-03 14 59 14

However, the detailed pages didn't have these related posts.
截屏2025-01-03 15 00 10

  1. Config in _config.next.yml as well, you can see the related posts then.
截屏2025-01-03 14 56 52

Node.js and NPM Information

v23.4.0
11.0.0

Package dependencies Information

hexo-site@0.0.0 /Users/chong.chen/myProjects/Hexo-Blog
├── hexo-abbrlink@2.2.1
├── hexo-algolia@1.3.2
├── hexo-deployer-git@3.0.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@2.0.0
├── hexo-generator-searchdb@1.4.1
├── hexo-generator-tag@1.0.0
├── hexo-graph@1.0.9
├── hexo-related-posts@1.5.2
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-marked@5.0.0
├── hexo-renderer-stylus@2.1.0
├── hexo-server@3.0.0
├── hexo-theme-next@8.22.0
├── hexo-word-counter@0.0.3
├── hexo@6.3.0
└── moment@2.30.1

Hexo Configuration

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

# Site
title: Erispyu's Blog
subtitle: ''
description: ''
keywords:
author: Erispyu
language: en
timezone: ''

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://erispyu.github.io
#permalink: :year-:month-:day-:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: false
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# 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
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repo: https://github.com/erispyu/erispyu.github.io
  branch: hexo
  name: erispyu
  email: erispyu@gmail.com

# Post wordcount display settings
# Dependencies: https://github.com/next-theme/hexo-word-counter
symbols_count_time:
  symbols: true
  time: true
  total_symbols: true
  total_time: true
  exclude_codeblock: false
  awl: 4
  wpm: 275
  suffix: "mins."


algolia:
  applicationID: "2BILQUWIOA"
  apiKey: "f5aabb895c10440c28e6c77090f511eb"
  indexName: "github_page_erispyu"


# https://github.com/ohroy/hexo-abbrlink
permalink: posts/:abbrlink/
abbrlink:
  alg: crc32
  rep: hex
  drafts: false
  force: false
  writeback: true


related_posts:
  enable: true
  icon: fa fa-signs-post
  filter_threshold: 0.001
  related_count: 5
  weight:
    title: 0.1
    author: 2
    description: 0.08
    keywords: 0.05
    tags: 0.1
    categories: 0.05
    text: 1

NexT Configuration

# ---------------------------------------------------------------
# Menu Settings
# ---------------------------------------------------------------

# Usage: `Key: /link/ || icon`
# Key is the name of menu item. If the translation for this item is available, the translated text will be loaded, otherwise the Key name will be used. Key is case-sensitive.
# Value before `||` delimiter is the target link, value after `||` delimiter is the name of Font Awesome icon.
# External url should start with http:// or https://
menu:
  home: / || fa fa-home
  about: /about/ || fa fa-user
  tags: /tags/ || fa fa-tags
  categories: /categories/ || fa fa-th
  archives: /archives/ || fa fa-archive
  Reading Progress: /reading-progress/ || fa fa-book-open
  Stats: /stats/ || fa fa-bar-chart
  #schedule: /schedule/ || fa fa-calendar
  #sitemap: /sitemap.xml || fa fa-sitemap
  #commonweal: /404/ || fa fa-heartbeat


# ---------------------------------------------------------------
# Scheme Settings
# ---------------------------------------------------------------

# Schemes
scheme: Muse
# scheme: Mist
# scheme: Pisces
# scheme: Pisces

# Dark Mode
darkmode: true


# ---------------------------------------------------------------
# Site Information Settings
# ---------------------------------------------------------------

# Creative Commons 4.0 International License.
# See: https://creativecommons.org/about/cclicenses/
creative_commons:
  # Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | cc-zero
  license: by-nc-sa
  # Available values: big | small
  size: big
  sidebar: true
  post: true
  # You can set a language value if you prefer a translated version of CC license, e.g. deed.zh
  # CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org
  language:


# ---------------------------------------------------------------
# Sidebar Settings
# See: https://theme-next.js.org/docs/theme-settings/sidebar
# ---------------------------------------------------------------

# Table of Contents in the Sidebar
# Front-matter variable (nonsupport wrap expand_all).
toc:
  enable: true
  # Automatically add list number to toc.
  number: false
  # If true, all words will placed on next lines if header width longer then sidebar width.
  wrap: false
  # If true, all level of TOC in a post will be displayed, rather than the activated part of it.
  expand_all: false
  # Maximum heading depth of generated toc.
  max_depth: 6


# ---------------------------------------------------------------
# Custom Page Settings
# See: https://theme-next.js.org/docs/theme-settings/custom-pages
# ---------------------------------------------------------------

# TagCloud settings for tags page.
tagcloud:
  min: 12 # Minimum font size in px
  max: 30 # Maximum font size in px
  amount: 200 # Total amount of tags
  orderby: date # Order of tags
  order: 1 # Sort order


# ---------------------------------------------------------------
# Misc Theme Settings
# See: https://theme-next.js.org/docs/theme-settings/miscellaneous
# ---------------------------------------------------------------

codeblock:
  # Add copy button on codeblock
  copy_button:
    enable: true
    # Available values: default | flat | mac
    style: default

back2top:
  enable: true
  # Back to top in sidebar.
  sidebar: false
  # Scroll percent label in b2t button.
  scrollpercent: true


# ---------------------------------------------------------------
# Animation Settings
# ---------------------------------------------------------------

# Use the Canvas Nest animation
# For more information: https://github.com/theme-next/theme-next-canvas-nest
custom_file_path:
  #head: source/_data/head.swig
  #header: source/_data/header.swig
  #sidebar: source/_data/sidebar.swig
  #postMeta: source/_data/post-meta.swig
  #postBodyEnd: source/_data/post-body-end.swig
  footer: source/_data/footer.swig
  #bodyEnd: source/_data/body-end.swig
  #variable: source/_data/variables.styl
  #mixin: source/_data/mixins.styl
  #style: source/_data/styles.styl


social:
  GitHub: https://github.com/erispyu || fab fa-github
  E-Mail: mailto:erispyu@gmail.com || fa fa-envelope
  Goodreads: https://www.goodreads.com/user/show/156410162-erispyu || fa fa-book-reader
  Douban: https://www.douban.com/people/erispyu00/ || fa fa-film


# Algolia Search
algolia_search:
  enable: true
  hits:
    per_page: 10


tag_icon: true


#related_posts:
#  enable: true
#  icon: fa fa-signs-post
#  filter_threshold: 0.001
#  related_count: 5
#  weight:
#    title: 0.1
#    author: 2
#    description: 0.08
#    keywords: 0.05
#    tags: 0.1
#    categories: 0.05
#    text: 1

Other Information

No response

@erispyu erispyu added the Bug Something isn't working label Jan 3, 2025
Copy link

welcome bot commented Jan 3, 2025

Thanks for opening this issue, maintainers will get back to you as soon as possible!

@erispyu erispyu changed the title need to config related_posts filter_threshold & weight both in _config.yml and _config.next.yml need to config Related-Popular-Posts both in _config.yml and _config.next.yml Jan 3, 2025
@erispyu
Copy link
Author

erispyu commented Jan 3, 2025

If only config in next yml, the hexo-related-post would fail to load the weight and threshold values, then use the default ones.

@sghuang19
Copy link
Member

@erispyu Have you tried updating to the latest version of hexo (v7.3.0)?

@sghuang19 sghuang19 added the Need More Info Further information is requested label Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

We would appreciate it if you could provide us with more info about this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Need More Info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants