Hexo: after set post_asset_folder: true and root: /xxxx/锛宼he image url was wrong

Created on 30 Aug 2016  路  7Comments  路  Source: hexojs/hexo

Environment Info

Node version(node -v)

v6.4.0

site _config.yml

# Hexo Configuration
路路路
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Allen's Blog
subtitle:
description:
author: ""
email: ""
language: zh-Hans
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://pages.xxx.com/xxx/blogs
root: /xxx/blogs/
permalink: articles/:year-:month/:title/
permalink_defaults:

# 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: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: false
future: false
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: true

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# 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

# 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: landscape
#theme: yilia
# Deployment
## Docs: https://hexo.io/docs/deployment.html

Your theme _config.yml

# Header
menu:
  Home: /
  Archives: /archives
rss: /atom.xml

# Content
excerpt_link: Read More
fancybox: true

# Sidebar
sidebar: right
widgets:
- category
- tag
- tagcloud
- archive
- recent_posts

# display widgets at the bottom of index pages (pagination == 2)
index_widgets:
# - category
# - tagcloud
# - archive

# widget behavior
archive_type: 'monthly'
show_count: false

# Miscellaneous
google_analytics:
favicon: /favicon.png
twitter:
google_plus:
fb_admins:
fb_app_id:

Plugin version(npm ls --depth 0)

D:\workspaces\hexo-blogs>npm ls --depth 0
[email protected] D:\workspaces\hexo-blogs
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

For BUG

After set post_asset_folder: true and root: /xxxx/锛宼he image url was wrong, ref images in post like this

{% asset_img export_cert_3.png vbooking.cer %}

# producted URL
<meta property="og:image" content="http://pages.xxx.com/xxx/blogs/xxx/blogs/articles/2016-08/resolve-java-app-ssl-error/export_cert_3.png">

stale wontfix

Most helpful comment

I have same issue. Root url is always prefixed twice.

All 7 comments

What is the expected url for that image?

@NoahDragon I put my site in a subdirectory xxx/blogs under the site http://pages.xxx.com/, as the comment said:

If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'

So I set url to http://pages.xxx.com/xxx/blogs and root to /xxx/blogs. As my expected, the image url should be http://pages.xxx.com/xxx/blogs/articles/2016-08/resolve-java-app-ssl-error/export_cert_3.png not http://pages.xxx.com/xxx/blogs/xxx/blogs/articles/2016-08/resolve-java-app-ssl-error/export_cert_3.png, it add unnecessary /xxx/blogs to image url.

How about your post url? I presume it also includes the redundant /xxx/blogs. If so, I think I'm on the right track.

PS: #1912 this PR solves similar issue for share link.

@NoahDragon on my index.html the post link is like that:

    <h1 itemprop="name">
      <a class="article-title" href="/child/articles/2016-10/test-img/">test-img</a>
    </h1>
      </header>
    <div class="article-entry" itemprop="articleBody">
        <img src="/child/articles/2016-10/test-img/example.jpg" alt="This is an example image" title="This is an example image">
    </div>

I think it is right, but in post the image url is wrong.

I will try #1912 , if it is work, I will let you know.

@NoahDragon I think it is not fix all the problem, my post html still have wrong url.

<meta property="og:type" content="article">
<meta property="og:title" content="test-img">
<meta property="og:url" content="http://allenn.cn/child/articles/2016-10/test-img/index.html">
<meta property="og:site_name" content="Allen's Blog">
<meta property="og:image" content="http://allenn.cn/child/child/articles/2016-10/test-img/example.jpg">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="test-img">
<meta name="twitter:image" content="http://allenn.cn/child/child/articles/2016-10/test-img/example.jpg">

I have same issue. Root url is always prefixed twice.

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings