Search code examples
yamljekyll

What is the syntax to create a pdf link in _config.yml


I am using Jekyll to create a personal website. I am using the Beautiful-Jekyll template that is very popular. There is a navigation bar already defined in _config.yml. I want to make Resume link to my resume pdf.

I have accomplished that with this code (in _config.yml):

# List of links in the navigation bar
navbar-links:
  Moi: "aboutme"
  Projects:
    - Hell Game: "http://deanattali.com/beautiful-jekyll/"
    - Success City: "http://www.markdowntutorial.com/"
  Resume: "Tech Resume.pdf"

However, this only opens the resume in the same tab. I want it to open in a separate tab. In HTML, you achieve this by using target="_blank". How do I do this in YAML?

I tried this but my index.html actually doesn't use links. I know, weird.


Solution

  • beautiful-jekyll/_includes/nav.html line 26:

    <a href="{{ linkparts[1] | relative_url }}">{{ linkparts[0] }}</a>
    

    Change it into:

    <a href="{{ linkparts[1] | relative_url }}" 
    {% if linkparts[1] contains '.pdf' %}target="_blank"{% endif %}
    >{{ linkparts[0] }}</a>
    

    Or use this (java)script/solution: https://jekyllcodex.org/without-plugin/new-window-fix/