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

Allow setting the permalink via collection config #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

grrowl
Copy link

@grrowl grrowl commented Dec 7, 2015

I don't use the image/assets/ stuff, and I like .html files generated.

@fj
Copy link
Owner

fj commented Mar 20, 2016

Thank you for submitting a PR.

I'm a little confused by this, though; what do you want the result of setting a permalink to be? This seems like it's going to overwrite your choice for permalinks if you specify it in the configuration.

Previous commit allowed collections.[collection].permalink to be set, but 
disabled proper collection permalink generation
@grrowl
Copy link
Author

grrowl commented Mar 21, 2016

Rightfully so, this is a bad pull request. I pulled apart the code after not having touched Jekyll in months:

  • I was attempting to add the below code to my _config.yml so spicy-jekyll would output .html files instead of directories of index.html files
collections:
  issues:
    refname: issue
    output: true
    permalink: /:collection/:slug.html
  • In my naivety I thought d.data['permalink'] would have this config variable in it— it doesn't.
  • Therefore, d.data['permalink'] is always nil, and the permalink is never set and, somehow, the value in the _config.yml is used.
  • If permalink is not set in the config, it falls back to the Jekyll default, which in my case is something like /issue/issue-the-slug-name (note the collection name in the permalink twice)

It seems be that the line should read if not collection.metadata['permalink'] instead, but this will still have the collection name prepended to :slug, which the affected line of code obviously addresses. I've updated my branch but understand if you'll just close the PR.

Sorry again, cheers!

@fj
Copy link
Owner

fj commented Mar 21, 2016

Ah, right, so the d.data['permalink'] is from an individual document's permalink attribute -- that is, what you'd see in the document's YAML frontmatter. It's not on the collection (which would be in _config.yml).

So it sounds like what you want is a "permalink formatter", where you can specify a string like /:collection/:slug.html and have it be substituted at generation time. That's probably outside the scope of this tool, but it would be a great candidate for a downstream plugin that makes another pass over the documents and adds the permalinks you're describing.

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

Successfully merging this pull request may close these issues.

2 participants