Search code examples
githubmarkdownjekyllgithub-pagesgithub-flavored-markdown

How do I turn a h2 Markdown header into a link?


I'm new to creating sites with Jekyll and markdown in general, so please tell me if there is something obviously wrong with my approach.

My code is:

[## Red Hat Certified Systems Administrator (RHCSA) Guide]({% post_url 2017-09-11-RHCSA %})

The output I was expecting was an h2 Header that's also a link. However, when I serve the page using Jekyll, the link works perfectly, but instead of the link text being a h2 header, it simply contains ## Red Hat Certified Systems Administrator (RHCSA) Guide.

So, how do I nest the <h2> tag inside the <a href> tag using markdown?


Solution

  • Okay, guys... turns out I've been monumentally stupid. While I'm still confused why the markdown won't accept a header tag inside the link, there's a simple workaround!

    Simply put the ## tag outside the link's brackets. Thus, the proper code (that works) is:

    ## [Red Hat Certified Systems Administrator (RHCSA) Guide]({% post_url 2017-09-11-RHCSA %})
    

    So, a link to Google.co.in would become:

    ## [Google](https://google.co.in)
    

    Output :

    Google

    Thanks to all that viewed the question and tried to help.

    I leave this here in hopes that one day some unfortunate soul lands here in the same predicament as I did and finds this.