Default slug

This is really a Forestry issue, but I wanted to see if anyone has any ideas.

Problem: the page slug is typically based on the title. This is fine as a default, but is a real pain when someone tweaks the title after the page has been published, and linked to, and shared on social media. Then it seems like a really, really bad idea.

Solution: make the default slug the file name so that it is no longer tied to the title. To do that, put the following in config.toml:

  post = ":section/:year/:month/:slug/"

and add the following to archetypes/

slug: '{{ .File.BaseFileName }}'

Problem solved, except we are using Forestry, which does not use archetypes to create files. Forestry uses its front matter templates to create files and has no way that I can find to set the default slug to the file name.

have you try {{ .Name }}?

Wouldn’t you still have the same problem? Since most people name the file and title similarly

Musing on it, do folks change file names when updating content? I don’t think it happens for most web writers, and in this case they are changing front matter via Forestry… I don’t know how that works, but it seems like “moving” files around is not a focus.

@rbottomley, have you tried :filename in the permalink pattern? That seems like it would do what you want, without having to set the slug.

I see what you’re saying.

But, if the desire is for the permalink to match up with the title, then I think keeping the original permalink pattern and then using front matter aliases is a better solution.

But no one ever changes the file name. Forestry doesn’t even have a way to do that that I know of. The problem is that the marketing people regularly tweak titles after something has gone live.

Using :filename would solve part of the problem: the URL would no longer change when the title is edited. The problem now is that we did want to offer the option of setting the slug. I did test to see if slug would override filename and it doesn’t.

I don’t use Forestry, so I’m unaware of which front matter they expose for editing. But that would be how I presumed it worked. Ganbatte! :slight_smile:

No, matching the permalink to the title was never the desire (and I really hate the stupidly long URLs that read like sentences). We have also abandoned front matter aliases for two reasons: 302 redirects are not considered good for SEO and the marketing people not understanding redirects at all and putting the same three aliases on five different pages.

No, what I want is a slug that is pretty much set in stone once created and not something that shifts as text is edited — unless you really, really want to change it. Using :filename would give us the set in stone option, just without marketing people being able to adjust it.