Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically add .html to generated archives names without extension #102

Open
Exagone313 opened this issue Jul 23, 2017 · 2 comments
Open

Comments

@Exagone313
Copy link

Hi,

If you use an archive permalink that is not a directory and not ending by .html, such as /:year, it generates a file without extension, instead of adding .html (unlike with Jekyll's post permalink).

I'd like to add the html extension without having page.url containing it (would be the case if you use /:year.html).

Note that I actually use the v2.1.1 tagged version.

@davidc
Copy link

davidc commented Jun 11, 2020

This is exactly what we need and would add parity with how Jekyll's own permalinks work.

For example in Jekyll:

collections:
  posts:
    permalink: /posts/:year/:month/:day/:title

will produce files at /posts/2020/06/11/mypost.html
and permalink (page.url) of /posts/2020/06/11/mypost

The latter is how we want to serve them (and how they should appear in canonical links and sitemaps etc, which use the page.url variable)

However in Jekyll-archives:

jekyll-archives:
  permalinks:
    year: '/posts/:year'

will produce the correct permalink but output the wrong file (without .html extension)

and

jekyll-archives:
  permalinks:
    year: '/posts/:year.html'

will output to the right file but have the wrong permalink.

@Exagone313
Copy link
Author

Exagone313 commented Jun 12, 2020

A partial workaround is to strip .html when printing links to archives, but you can't fix it for plugins reading the permalink (such as for jekyll-sitemap).

{%- assign year_archives = site.archives | where:"type", "year" -%}
{%- for archive in year_archives reversed %}
<p class="center"><a href="{{ archive.url | replace: '.html', '' }}">{{ archive.date | date: "%Y" }}</a></p>
{%- endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants