Search code examples
jekyllliquidpermalinksjekyll-extensions

Is it possible to validate if a link (or string) matches with any valid Jekyll permalink?


Is it possible to validate if a link (or string) matches with any valid Jekyll permalink?

For example, I'm generating dynamically a navigation bar like this:

<li class="active">
  <a href="{{ base }}/{{ site.locale }}/about/the-project/">About</a>
</li>

Now, is it possible to know if "{{ base }}/{{ site.locale }}/about/the-project/" is a valid permalink ?

The idea is to skip that 'LI' tag if the link does not match with any valid permalink.


Solution

  • So, I'm using basically what I have for my sitemap.

    {% assign tmp_posts = site.posts | where:'locale', site.locale %}
    {% assign tmp_buildlogs = site.buildlog | where:'locale', site.locale %}
    {% assign all_posts = tmp_posts | concat: tmp_buildlogs %}
    

    Then, I can just check the links.