Closed liuyib closed 4 years ago
如果不运行 hexo deploy ,链接应该不会被推送。一般开发环境不会运行 hexo deploy 。
您遇到的情况是,在开发环境中,没有直接或间接(如 npm run dev )运行 hexo deploy ,但是链接仍然被推送了,对吗?
@cjh0613 开发环境下,我的命令是:
不包括 hexo deploy
,所以是不是个 BUG?
@cjh0613
Hexo 根目录下的 package.json:
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "4.0.0"
},
"scripts": {
"dev": "hexo clean && hexo s -p 8001 -o",
"build": "hexo clean && hexo d -g"
},
"dependencies": {
"hexo": "^4.0.0",
"hexo-algolia": "^1.3.1",
"hexo-deployer-git": "^1.0.0",
"hexo-generator-archive": "^0.1.5",
"hexo-generator-category": "^0.1.3",
"hexo-generator-feed": "^1.2.2",
"hexo-generator-index-pin-top": "^0.2.2",
"hexo-generator-search": "^2.4.0",
"hexo-generator-sitemap": "^2.0.0",
"hexo-generator-tag": "^0.2.0",
"hexo-render-pug": "^2.1.4",
"hexo-renderer-ejs": "^0.3.1",
"hexo-renderer-markdown-it-plus": "^1.0.4",
"hexo-renderer-stylus": "^0.3.3",
"hexo-server": "^0.3.3",
"hexo-wordcount": "^6.0.1"
}
}
Hexo 配置文件:
# Site
title: Liuyib's Blog
subtitle: write code and love life
description: 博客,分享,开源,心得
author: liuyib
language: zh-CN
timezone:
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://liuyib.github.io/
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
# Set to false to remove trailing index.html from permalinks
pretty_urls:
trailing_index: false
# 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: true
auto_detect: false
tab_replace: false
hljs: false
# 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
## Use post's date for updated date unless set in front-matter
use_date_for_updated: false
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: stun
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
- type: git
repo: git@github.com:liuyib/liuyib.github.io.git
branch: master
# See: https://github.com/hexojs/hexo-generator-sitemap
sitemap:
path: sitemap.xml
# See: https://github.com/hexojs/hexo-generator-feed
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: " "
order_by: -date
# icon: icon.png
# Algolia Search API Key
algolia:
applicationID: "xxxxxxxxxxxxxxxxxxxxxx"
apiKey: "xxxxxxxxxxxxxxxxxxxxxx"
indexName: "xxxxxxxxxxxxxxxxxxxxxx"
# Local Search
search:
path: search.json
field: post
content: true
可以查到具体是哪个命令触发了推送吗?
@cjh0613 我用的命令里面 hexo clean && hexo s -p 8001 -o
,hexo clean
肯定不是,后面指定端口和自动打开浏览器的参数 -p -o
也肯定不是,那就是 hexo s
触发的了
经我验证,"hexo": "^4.2.1","hexo-server": "^1.0.0"下运行 hexo server 不会触发推送。
hexo 和 hexo-server 的版本号上面我贴出来了,和你验证用的版本号不一样,你有时间可以验证下
我用的插件和版本号都贴出来了,我能遇见这个问题,就证明 hexo-submit-urls-to-search-engine 存在这方面的 Bug,想不想解决看你了。
不想解决的话,你至少要清楚,hexo 和 hexo-server 多少版本有这个问题,而不是你验证 "hexo": "^4.2.1","hexo-server": "^1.0.0"
没问题,就好像在其他版本中 hexo-submit-urls-to-search-engine 没问题一样。
正在等待其他用户反馈,以初步确定有问题的版本 hexo 和 hexo-server 具体多少版本有这个问题及修复需要我之后研究 hexo 和 hexo-server 源码后给出,短时间无法解决。
@cjh0613 您好,我确认了下,这个问题实际不存在,当时我也比较忙以为是个 Bug。现在才发现,控制台输出的那些 URL 只是提示信息罢了。很抱歉带给你的麻烦 🙏
……
建议
答: 如题,一般不希望在开发环境中就向搜索引擎提交 URL,否则结果可想而知:
开发环境中,每次服务器刷新都会提交一次 URL,最后发现已经向搜索引擎提交了一万次 URL。。。。这样很可能被搜索引擎封掉。
其实,该插件只需要在
npm run build
时,也就是生产环境中执行一次就好了,开发环境真的没必要运行。