Skip to content

请教下如何给 hugo-ivy 主题左侧的导航菜单增加 icon 图标? #1525

Answered by chuxinyuan
chuxinyuan asked this question in Q&A
Discussion options

You must be logged in to vote

感谢百忙中花时间提供指导,精准定位问题,问题基本解决。在此梳理下:

修改 menu.html

打开 /themes/hugo-ivy/layouts/partials/menu.html 文件

<li{{ if eq .URL $currentPage.RelPermalink }} class="active"{{ end }}><a href="{{ .URL }}">{{ .Name }}</a></li>

修改为:

      <li{{ if eq .URL $currentPage.RelPermalink }} class="active"{{ end }}>
        <a href="{{ .URL }}">
          <i class="fa {{ printf "fa-%s" .Pre }}"></i>{{ .Name }}
        </a>
      </li>

修改 head_custom.html

/layouts/partials/head_custom.html 文件中增加如下代码:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">

修改 config.yaml

menu 下增加 一行代码 pre: home

menu:
  main:
    - name: "首页"
      url: "/"
      weight: 1
      pre: 

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@chuxinyuan
Comment options

Answer selected by yihui
@yihui
Comment options

@chuxinyuan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants