Detects links that don't work, missing images and redirects.
Want to see pretty graphs? Log in now!
npm install hexo-broken-link-checker
|9||downloads in the last week|
|15||downloads in the last month|
|Last Published By|
|Version||1.0.1 last updated 3 months ago|
|License||BSD 3-Clause License|
|Keywords||website, blog, hexo, broken, dead, link, redirection, 404, error, checker, console, command, plugin|
|Dependencies (14)||request, wrench, colors, JSONSelect, jsonfile, cli-table, prettyjson, cheerio, moment, puid, update-notifier, async, underscore.string, lockfile|
This is a hexo plugin which detects links that don't work, missing images and redirects.
Run the following command in the root directory of hexo:
npm install hexo-broken-link-checker --save
And enable the plugin in your
plugins: - hexo-broken-link-checker
_config.yml file and paste the following lines:
# hexo-broken-link-checker plugin link_checker: enabled: true storage_dir: temp/link_checker silent_logs: false
enabled: (boolean)- Enables or disables the post inspection for links.
storage_dir: (string)- Where do you want the plugin to store its files.
silent_logs: (boolean)- If
true, the logs will be placed in a log file instead of the console output.
Once you have all configured, you need to create a few files that will be used by this plugin. Run the following command:
hexo link_checker setup
You'll see something link this:
If, for some reason, you execute this command twice, you'll see a warning message:
link_checker command has an alias,
lc. That said,
hexo link_checker [arguments] and
hexo lc [arguments] are the same command.
First of all, make sure the plugin is enabled:
# _config.yml link_checker: enabled: true
This will automatically register a hexo post filter, which is a function that processes your already rendered posts. The post filter will be called every time you run
hexo generate, will extract and store all the links on your posts.
So, as I said, run:
And you'll see the following messages:
If you have a blog with 1000 posts, and each article has 2 external links, you'll have 2000 links to extract and check. That's a lot of operations just to check for success or error HTTP Codes, and that's why the extraction and scan are two different tasks.
hexo generate has finished the extraction process, you can run:
This command will take every link on the storage file and will make a HTTP request to it. All results will be stored on the same storage file.
Because this command is slow and passive, you can use a cron job to check all of your links in background. For example:
# Every day at 10PM, go to my blog directory, run the scanner and only store the errors on linkchecker_error.log 0 22 * * * cd /home/me/MyBlog/ && hexo lc scan 2> linkchecker_errors.log
Checking the scan results
hexo lc show-links [options]
Options can be:
--filter=[all|broken|ok|redirects|unverified]: filter links by status.
--id=[linkID]: shows detailed info of a link.
Checking the log files
hexo lc show-logs
The screenshot below shows the log file when you set
silent_logs: true into