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/blog
absolute:
enable: true
tagName: ["a", "link", "img", "script"]
attribute: ["href", "src"]
priority: 20
-
enable
boolean, set
false
to disable this plugin. -
tagName
html tag name
-
attribute
html tag attribute
-
priority
define 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