STC214/使用Hugo建立的博客使用Dream主题时开启搜索功能

Created Wed, 13 Jan 2021 18:13:37 +0800 Modified Wed, 13 Jan 2021 18:13:37 +0800

其他详细设置看官方说明:
https://g1eny0ung.site/hugo-theme-dream/

Dream主题中内置了搜索功能

只需要简单的设置即可开启这个功能

打开根目录下的 config.toml

在配置项中加入如下内容

原来配置文件中有[params]则在其中加入第二行即可

  
[params]  
  enableSearch = true  
  

之后添加如下内容

  
[outputs]  
  home = ["HTML", "RSS", "JSON"]  
  

原文:https://g1eny0ung.site/hugo-theme-dream/#/search

  
Search  
  
You can enable the search feature by setting the enableSeach param to true in [params]  
  
[params]  
  enableSearch = true  
  
Also, you need to set Hugo outputs to include JSON:  
  
# in your config.toml  
[outputs]  
  home = ["HTML", "RSS", "JSON"]  
  
Then you will see a search icon appear on the top of the nav. Click it or type Win+/(Windows) or CMD+/(macOS) to start searching.