Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't link to correct urls #15

Closed
nodingneu opened this issue Jan 21, 2017 · 12 comments
Closed

Doesn't link to correct urls #15

nodingneu opened this issue Jan 21, 2017 · 12 comments

Comments

@nodingneu
Copy link

I am in the process of setting up a hexo blog on my github pages.

This search plugin looks pretty impressive, but for some reason results redirect to blog/blog instead of just /blog.

Mind having a look into this?

@wzpan
Copy link
Owner

wzpan commented Jan 22, 2017

Please give me your configurations on the plugin.

@nodingneu
Copy link
Author

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://theonlygusti.github.io/blog
root: /blog/
permalink: :year/:month/:day/:title/
permalink_defaults:

@nodingneu
Copy link
Author

Every other plugin I have seems to work and handle urls correctly.

@wzpan
Copy link
Owner

wzpan commented Jan 22, 2017

What you give me is the setting of your site's root. Whereas I want the setting of you search plugin, for example:

search:
  path: search.xml
  field: all

I've wrote two themes for Hexo. One is hexo-theme-freemind and the other is hexo-theme-wixo. Both have used hexo-generator-search for local searching and are put in a subdirectory like your site does. And the plugin works like a charm on both sites. Maybe you can take a look at the settings of these two examples and try to figure out what is the underlying problem.

@nodingneu
Copy link
Author

I haven't set anything like that in my main _config.yml

@wzpan
Copy link
Owner

wzpan commented Jan 22, 2017

If you don't need that, you must have hard code it some where in the layout templates. Could you write down it for me? For example, here's the code I wrote for hexo-theme-freemind to load search.xml:

<% if (config.search) { %>
   <script type="text/javascript">      
     var search_path = "<%= config.search.path %>";
	 if (search_path.length == 0) {
	 	search_path = "search.xml";
	 }
	 var path = "<%= config.root %>" + search_path;
     searchFunc(path, 'local-search-input', 'local-search-result');
   </script>
<% } %>

See? You should pass an available path param that correctly points out the path to access your search.xml .

@nodingneu
Copy link
Author

I am using hexo-theme-material for my theme, maybe it isn't handling it correctly

@wzpan
Copy link
Owner

wzpan commented Jan 24, 2017

If you find difficult to customize your theme to support hexo-generator-search, then I would rather suggest you to use hexo-theme-freemind. The local search engine works out of box there.

I think I should have given you all the necessary info about how to set up the fire of hexo-generator-search. I will close this issue. If you still want more help, you can continue to ask me questions.

@pidupuis
Copy link

As you can see in the search.xml file generated by hexo-generator-search, the urls are already broken. The theme simply take the url. The problem seems to come from your part...

@nodingneu
Copy link
Author

@wzpan Actually, this still seems to be an issue relevant to the hexo-generator-plugin rather than the theme I'm using.

Your plugin generates the search.xml file, however this file is already creating the incorrect links, have a look at mine:

<url>http://theonlygusti.github.io/blog/blog/2017/01/21/first-post/</url>

It should be http://theonlygusti.github.io/blog/2017/01/21/first-post/

@wzpan
Copy link
Owner

wzpan commented Jan 25, 2017

@theonlygusti Then please give me the full code that you put the plugin to work. There must be something wrong with the path you ask the generator to parse the link.

@fomeiherz
Copy link

fomeiherz commented Mar 20, 2019

Link cannot redirect to correctly.
So I must change file: /themes/xxx/layout/partials/scripts.ejs
str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
change to:
str += "<li><a href='/" + data_url + "' class='search-result-title'>" + data_title + "</a>";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants