Convert relative path to absolute URL for hexo
Only run when hexo generate or deploy, won't run when hexo server.
pnpm add hexo-absolute
# npm i hexo-absolute# If your website is in a subdirectory (such as http://example.org/blog) set url to http://example.org/blog and set root to /blog/.
url: http://example.org/blogabsolute:
enable: true
tagName: ["a", "link", "img", "script"]
attribute: ["href", "src"]
priority: 20-
enableboolean, set
falseto disable this plugin. -
tagNamehtml tag name
-
attributehtml tag attribute
-
prioritydefine the priority of this plugin.
<a href="#top">top</a>
<link rel="stylesheet" href="/css/style.css" />
<img src="/images/hexo.png" />
<script src="/js/jquery-2.2.4.min.js"></script><a href="https://example.org/#top">top</a>
<link rel="stylesheet" href="https://example.org/css/style.css" />
<img src="https://example.org/images/hexo.png" />
<script src="https://example.org/js/jquery-2.2.4.min.js"></script>pnpm rm hexo-absolute
# npm uninstall hexo-absolute