Jekyll link within page

 ̄綄美尐妖づ 提交于 2019-12-10 13:00:07

问题


I'm using Jekyll on Github, and I wonder whether there's a way to link to a section within a page. Say I have a section like

## Section 1 ##
section content 

and later in the same page I want to link to this section. I've found how to link to another page within the blog and do footnotes, but not this.

As a note, I use markdown: kramdown in my _config.yml


回答1:


kramdown supports the automatic generation of header IDs if the option auto_ids is set to true (which is the default). This is done by converting the untransformed, i.e. plain, header text

So in the above example ## Section 1 ##, it would generate the following id: id="section-1", then the anchor is linked to via the A element:

<A href="#section-1">Section One</A>

Or in plain kramdown/markdown: [Section 1](#section-1)




回答2:


It seems that this has been changed to #heading-section-1 (checking on Jekyll 3.7.3 right now).

As a way to figure this out on your own, you can inspect the element and see the id being used on the rendered page.



来源:https://stackoverflow.com/questions/43627485/jekyll-link-within-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!