Automated Hexo Seo Optimizer.
- Auto add anchor title (if not exists)
- Auto determine anchor external link and nofollow them
Auto replace broken images- Auto compress CSS JS HTML
- Auto add alternate and title of images
- Auto add sitemap (forked from yoast seo wordpress plugin)
- Auto add google news sitemap
- Tested on hexo instances with 1000 more posts and pages
- Concatenate all javascripts into one file
- Rich snippets (breadcrumbs, website, article)
Separated due to very high memory usage and risk of HEAP MEMORY errors. so I will merge it to https://github.com/dimaslanjaka/static-blog-generator as a specific task
demo site generated with hexo-seo
npm install hexo-seonpm install hexo-seo@https://github.com/dimaslanjaka/hexo-seo/raw/pre-release/release/hexo-seo.tgzUsing a tarball is helpful if git is not installed properly or for users in mainland China.
| Description | Link |
|---|---|
| Master tarball | https://github.com/dimaslanjaka/hexo-seo/raw/master/release/hexo-seo.tgz |
| Pre-release tarball | https://github.com/dimaslanjaka/hexo-seo/raw/pre-release/release/hexo-seo.tgz |
You can replace
masterorpre-releasewith a specific commit hash for a targeted version.
npm install hexo-seo@https://github.com/dimaslanjaka/hexo-seo/raw/<commit>/release/hexo-seo.tgzReplace <commit> with a specific commit hash, or use pre-release for the latest patch.
When using the latest
pre-release, always clear npm/yarn caches before installing.
# https://github.com/dimaslanjaka/hexo-seo
seo:
# enable persistent cache for faster builds
cache: true
# blog hostname (auto-detected if omitted)
host: yoursite.com
# minify html
html:
enable: true
# fix invalid html
fix: true
# exclude from minify
exclude:
- "*.min.{htm,html}"
# collapse boolean attributes (default: true)
collapseBooleanAttributes: true
# remove unnecessary whitespace (default: true)
collapseWhitespace: true
# ignore custom comments (regex supported)
ignoreCustomComments:
- "^\s*more"
# remove HTML comments
removeComments: true
# remove empty attributes
removeEmptyAttributes: true
# remove type="text/javascript" from script tags
removeScriptTypeAttributes: true
# remove type="text/css" from style/link tags
removeStyleLinkTypeAttributes: true
# minify inline JS
minifyJS: true
# minify inline CSS
minifyCSS: true
# minify css
css:
enable: true
# If you want to customize the css minifier settings, you can put below
# exclude css from minifying, multiple supported
exclude:
- "*.min.css"
- "**/*.min.css"
# minify js
js:
enable: true
# concatenate all js into one tag
## WARNING: DO NOT USING ANOTHER MINIFIER PLUGIN
concat:
enable: false
# download external JS before concatenation
download_external: false
# If you want to customize the js minifier settings, you can put below
# exclude js from minifying, multiple supported
exclude:
- "*.min.js"
- "**/*.min.js"
# this is terser options, you can customize minifier with terser options
# https://github.com/terser/terser?tab=readme-ov-file#minify-options-structure
# below is config example
options:
compress:
dead_code: true
mangle:
toplevel: true
safari10: true
# rich snippets
schema:
# produce schema for page and post
article:
enable: true
# produce schema for breadcrumb
breadcrumb:
enable: true
# produce schema for sitelink
sitelink:
enable: true
searchUrl: https://www.webmanajemen.com/search?q={search_term_string}
# produce schema for homepage
homepage:
enable: true
# this function still under development because JAVASCRIPT HEAP MEMORY and my device is 8GB RAM
img:
enable: true
# fix broken images
broken: false
# default broken/missing images
# https://github.com/dimaslanjaka/hexo-seo/blob/f4cf27fbc7de2b831462d3b26cf70ece2499d15b/src/search/index.ts#L53
default: https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg
# broken images methods
# serverside : process broken images from server side (caused javascript heap out of memory, if your post large and your device has insufficient memory)
# clientside : process broken image from client side browser with webjs
onerror: serverside
# external links fix
links:
# enable or false
enable: true
# open external links in new tab
blank: true
# allowed following links, otherwise nofollow others
allow:
- webmanajemen.com
# exclude these domains from nofollow
exclude:
- webmanajemen.com
- web-manajemen.blogspot.com
# seo-friendly sitemap
# you can fill value `sitemap: true` to create both sitemaps
sitemap:
# auto generate seo friendly sitemap on http://yoursite.com/sitemap.xml
# forked from yoast seo
# location: /sitemap.xml /page-sitemap.xml /post-sitemap.xml /category-sitemap.xml /tag-sitemap.xml
yoast: true
# google news sitemap
# location: /google-news-sitemap.xml
gnews: true
# sitemap.txt
# location: /sitemap.txt
txt: true
search:
# hexo seo-search page type to index
type: ['page', 'post']
feed:
# hexo seo-feed page type to index
type: [page, post]
# site icon for rss (PNG, JPEG, GIF)
icon: 'https://w7.pngwing.com/pngs/745/306/png-transparent-gallery-image-images-photo-picture-pictures-set-app-incredibles-icon-thumbnail.png'Generate json data for all published posts or pages (based on config.seo.search.type)
Support generate more than 1k pages on device RAM 8 GB
json data saved on
public_dir/hexo-seo-search.jsonandsource_dir/hexo-seo-search.json
hexo seo-searchSearch data result
Generate RSS 2.0 and ATOM file
hexo seo-feedGenerated file written to
- RSS:
public_dir/rss.xmlandsource_dir/rss.xml - ATOM:
public_dir/atom.xmlandsource_dir/atom.xml
This plugin support parsing these customized metadata
By default hexo author is string with value author name
author: Author NameFor this plugin, we can put author metadata with more complex information. Reference
author:
name: Author Name
link: http://facebook.com/authorUsername
email: [email protected]This parser supported for site config (_config.yml) and post markdown and page markdown.
hexo.on('exit')not called at end of process
no more issue Hexo On Exit Event this plugin already have schedule function
- node_libcurl binding not found
sudo apt-get install libcurl4-openssl-dev -y
# run below codes only if above package already installed
rm -rf node_modules/node-libcurl
npm install node-libcurl --build-from-source- Fix javascript heap out of memory
# POSIX
export NODE_OPTIONS=--max_old_space_size=8096
# windows
set NODE_OPTIONS=--max_old_space_size=8096- important after you update this plugin, you could cleaning the temp folders with:
hexo clean # this will cleaning temporarily folders of this pluginWhen these features are executed within the Hexo process, they generate arrays that match the size of all pages or posts. This can lead to out-of-memory heap errors, especially on devices with only 8 GB RAM or in limited environments like Free GitHub Actions (CI).
To avoid this, the recommended best practice is to run these processes separately via the CLI.



[ { "title": "Blockquote Shortcode", "date": "2023-04-08T15:30:00.691Z", "updated": "2023-04-08T15:30:00.691Z", "slug": "blockquote", "excerpt": "", "permalink": "http://www.webmanajemen.com/docs/hexo-seo/blockquote.html", "layout": "post", "objectID": "54fb9f4665464c46cd47ce1259af43a1", "date_as_int": 1680967800, "updated_as_int": 1680967800, "categories": [ { "name": "hexo", "path": "categories/hexo/" } ], "tags": [ { "name": "blockquote", "path": "tags/blockquote/" }, { "name": "shortcode", "path": "tags/shortcode/" } ], "author": "Dimas Lanjaka" }, // and more data here ]