Hexo-theme-next: Post `#more` link in browser bar then `<!-- more -->` mark used in `*.md` content. [solved]

Created on 11 Apr 2018  ·  5Comments  ·  Source: theme-next/hexo-theme-next

What's mean more<!-- more --> tag?

More tag usually used when we need excerpt post content in homepage. And when we press «Read More» button, in browser bar will added #more link to current URL. And, yes, it is SEO-sensitivity.

Steps to reproduce

  1. For example, in *.md file we write:
---
permalink: post-more-link
title: Post More Link Test
date: {{ date }}
tags: [Post, More, test]
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<!--more-->

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  1. Then we generate this post, go to homepage and see under «Read More» button permalink with #more suffix at the end:

image

  1. And after the click «Read More» button browser will close post, scroll down to <!-- more --> section and we must now stay on http://localhost:777/post-more-link/#more URL:

image

What is current behaviour?

For now #more link can be translated in languages here:

https://github.com/theme-next/hexo-theme-next/blob/30bccfc87578510c55774064b3e7994df90e019b/languages/en.yml#L31

So, if we will choose zh-HK language:

https://github.com/theme-next/hexo-theme-next/blob/30bccfc87578510c55774064b3e7994df90e019b/languages/zh-HK.yml#L27

In our browser bar permalink will http://localhost:777/post-more-link/#更多:

image

Plus it create additional bug because can't decode this URL correctly:

image

I think this bug can be fixed ASAP, but there are another additional suggestions about #more link.

Suggestions?

For now i see similar ways to refactor this link:

  1. Stay #more in language files and just fix bug for correct URL decoding.
    But it can be uncomfortable for some users and unsupported by some browsers.
    As for me, i not translate this link because my domain (e.g. almostover.ru) have english name and all permalinks have EN words too. And if my domain will in cyrillic language (e.g. книги-мавроди.рф), then, of course, i will want to see translated permalinks in browser bar (книги-мавроди.рф/искушение-сын-люцифера/#далее).
  2. Move #more from language files to NexT config and set as:
    yml post_meta: more:
    So, in this way will be used default value (*/#more) and if anyone want, he can define his own #more link translate (like custom menu/submenu items):
    yml post_meta: more: 更多

BTW

Actually, this feature was added in this pull (PART 3), but before we have no custom languages support, i think it's not comfortable for most users.

Up vote

http://www.easypolls.net/poll.html?p=5ace0ed0e4b0f7307b1720cd

P.S. If anyone have no access to easypolls.net service, just:

  1. Like for first variant: :+1:
  2. Dislike for second: :-1:

And i voted for second, so, i need to dislike myself, lol :smiley:

Bug Solved

Most helpful comment

I suggest that force to #more and ignore languages, anyway, using other languages instead of English in URLs is not smart, I think. Usually people who are not programmers set their SSID or hostname to Chinese and cause a lot of troubles, but most Hexo users are programmers, I think, and they will agree
using English.

All 5 comments

Force #more instead #{{ __('post.more') }} regardless of languages in post link?

https://github.com/theme-next/hexo-theme-next/blob/8043ed131721ca06835683bc560bec6712501c50/layout/_macro/post.swig#L324

Force #more instead #{{ __('post.more') }} regardless of languages in post link?

I see that variant too, as 3rd variant: roll back just for #more without any translate.
And actually, i find this file and as we can see, with translated #more link option scroll_to_more: true will not work, will not scroll to <a id="more"></a> id in post.

So, here is that bug: if option scroll_to_more enabled, jquery can't find targeted ID and return error.
But this bug can be avoided, of course, by adding custom excerpt.js or something like this. But question is: is it needed and important? Just for one #more functions and one scroll_to_more: true option which can be disabled, we have this bug and some troubles with default translate files.

I just suggest to move this translate to NexT config and set default as #more.
Or force set #more to default, by removing lagnuage translating.

I suggest that force to #more and ignore languages, anyway, using other languages instead of English in URLs is not smart, I think. Usually people who are not programmers set their SSID or hostname to Chinese and cause a lot of troubles, but most Hexo users are programmers, I think, and they will agree
using English.

Merged #more as default for now. The post.more in lang yml file is kept at present.

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.

Was this page helpful?
0 / 5 - 0 ratings