建立网站后,mkdocs搜索栏不起作用 [英] mkdocs search bar is not working after building site

查看:95
本文介绍了建立网站后,mkdocs搜索栏不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网站上的搜索栏不起作用.而当我在localhost服务时,它正在工作.

The search bar on the site is not working after building MKDOCS. Whereas when I serve in localhost it's working.

构建mkdocs之后,是否有任何变通办法可以利用搜索栏.

Is there any workaround for this to make use of the search bar after building mkdocs.

推荐答案

仅当从服务器为站点提供服务时,搜索才有效.当您使用 file://查看文件时,它不起作用.这是浏览器的安全设置所造成的限制(JavaScript代码无法通过 file://访问 search-index.json 文件),我不建议您禁用这些设置.您可能会找到第三方插件和/或主题,该插件和/或主题可以通过以不同格式重新创建索引文件来提供解决方法,以便可以通过< script> 标记而不是ajax请求来加载该索引文件.

Search only works when the site is served from a server. It does not work when you are viewing the files using file://. This is a limitation imposed by your browser's security settings (the JavaScript code cannot access the search-index.json file over file://) and I do not recommend that you disable those settings. You may find a third-party plugin and/or theme which provides a workaround by recreating the index file in a different format so that it can be loaded via a <script> tag rather than an ajax request.

这篇关于建立网站后,mkdocs搜索栏不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆