question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add automatic `fileSlug` key from file name

See original GitHub issue

Match {slug-name}.md or YYYY-MM-DD-{slug-name}.md

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
paulrobertlloydcommented, Apr 19, 2018

Any progress on this one? I tried to patch it by creating a filter and using this in permalink creation, but turns out that page.url returns an incorrect value when using this approach — another bug?

Given the filter I created, while the desired files are created (/path/to/slug.html), page.url returns /path/to/.html (slug is missing). 🤔

2reactions
kleinfreundcommented, Mar 26, 2018

At this point in the world of static site generators, index.* is a special breed. Its main use is creating extension-less permalinks (e.g. thing/index.html can be reached at thing/ if the web server is set up that way).

Now inferring the slug from a file’s name would generate index from index.html and thing from thing.md. That’s very consistent. However, it’s not useful. In this case, it would mean trading consistency for the capability of writing meta data-less content.

As shown above, in a directory-specific data file one can specifiy a dynamic permalink based on {{ slug }}. However, one would not be able to generate an index.html at the root of that directory as the consistent solution always creates a slug; thus, a sub-directory will be created.

Another thought: thing.md producing thing/index.html is already inconsistent. Is index the title of that document? thing seems to be the slug. Then index can’t be. If index is not the slug, why is index.html resulting in index/indext.html?

Also, let me just clarify that I see why this rings your alarm bells. Breaking consistency always does. Let me know if I should clarify some bits. I’ve got the feeling that this already sounds rather abstract.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permalinks — Eleventy
Eleventy automatically helps you make sure that Cool URIs don't change. What to leave out… File name extension. This is a very common...
Read more >
Renaming files: annoying automatic re-selection of entire
At first, I would wait a few seconds, hit "Home" or the left arrow key, and then work on renaming the file hoping...
Read more >
Architecting data in Eleventy - Sia Karamalegos
In my /posts/ folder, I can create a file with the same name as the folder and with either a .json , .11tydata.json...
Read more >
Auto-Enter a File Name - YouTube
Grabbing the name from a document inserted into a FileMaker Container field can be done with the Auto -Enter feature and the ...
Read more >
How would you make a unique filename by adding a number?
public FileInfo MakeUnique(string path) { string dir = Path.GetDirectoryName(path); string fileName = Path.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found