I have a Jekyll setup that looks like this:
_config.yml
_records
a.html
b.html
c.html
...
I want to create a home page that links to each record. However, I want to render a.html
and b.html
to /records/
, but I don't want to render c.html
to /records/
, as that HTML will be provided to my server from a different process altogether.
I tried setting the following in _config.yml
:
exclude:
_records/c.html
But this also removes c.html
from site.records
, which is not what I want. The best solution I have right now is to prevent my deploy script from deploying _site/records/c.html
, but I'd much rather prevent _site/records/c.html
from being generated in the first place.
Is it possible to include c.html
in site.records
to create the links on the home page but not render /records/c.html
? Any help others can offer with this question would be greatly appreciated!
Here's how I did this. Inside _records/c.html
, set in the front matter:
permalink: '_'
route: /records/c.html
That will make it so that we render the page's html content to _site/_.html
, a route that won't ever get visited.
Then in index.html
to create the link to the route
attribute of this page, use:
{% for record in site.records %}
{% if record.route %}
{% assign url = record.route %}
{% else %}
{% assign url = record.url %}
{% endif %}
<a href='{{ url }}'>{{ record.title }}</a>
{% endfor %}