assemble / grunt-assemble-permalinks

Permalinks middleware for Assemble, the static site generator for Grunt.js and Yeoman. This plugin enables powerful and configurable URI replacement patterns, presets, uses Moment.js for parsing dates, and much more.
MIT License
43 stars 11 forks source link

Predefine permalink style #6

Closed hariadi closed 10 years ago

hariadi commented 10 years ago
'date': '/:categories/:year/:month/:day/:filename'
'pretty': '/:categories/:year/:month/:day/:title/index.html'
'none': '/:categories/:filename'

And Assemble conf:

options: {
  permalinks: {
    plugins: ['permalinks'],
    pattern: 'pretty', // or :pretty
  }
}
jonschlinkert commented 10 years ago

Seems like this is a good use case for lo-dash templates:

links: {
  date  : '/:categories/:year/:month/:day/:filename'
  pretty: '/:categories/:year/:month/:day/:title/index.html'
  none  : '/:categories/:filename'
},

options: {
  permalinks: {
    plugins: ['permalinks'],
    pattern: '<%= links.pretty %>'
  }
}

however, I was thinking the same thing as you, so it's likely we'll get this request again. should we just add a few defaults in?

hariadi commented 10 years ago

:+1:

So what you suggest for default pattern?

jonschlinkert commented 10 years ago

For your own projects I would suggest just doing :category/:slug/index.html or something like that (with slug being a custom property/replacement pattern). like this: https://github.com/assemble/permalinks#seo

Date is generally bad for SEO, but a lot of people ask for it in permalinks, so I made sure it was prominent.

hariadi commented 10 years ago

Yes, IMO, :category/:slug is great for SEO. But there is challenge when page has multi categories (default first category).

Example yfm:

title: Multi Cats
categories:
  - Cat 1
  - Cat 2

With conf:

options: {
  permalinks: {
    plugins: ['permalinks'],
    pattern: 'seo', // :category/:slug
  }
}

Assemble should render to different page (page.dest become an array?):

  1. dest + '/cat-1/multi-cats/index.html'
  2. dest + '/cat-2/multi-cats/index.html'

Maybe this another issue.

jonschlinkert commented 10 years ago

I'm not sure, @doowb and I just had a similar conversation about the categories/index pages. How does WordPress do this? Or rather, how do you think WordPress might go about this if there wasn't a database involved?

jonschlinkert commented 10 years ago

I was just talking to @doowb and we're thinking we should probably build another "generic" plugin for indexing pages - that's all it would do. then we can always borrow some logic from that in other plugins if necessary. or even just create utils to use in other plugins for things like indexing, link building, pagination/paging, etc.

Just a thought, but I think the challenge with the index pages "muddy the waters". I'd love to neutralize that problem so we can think clearly about what we want to accomplish here.

jonschlinkert commented 10 years ago

@hariadi, see https://github.com/assemble/permalinks#preset. Let me know if this concept works for you, if so we can add more patterns. Next we'll need to decide what the patterns should be for each preset.

hariadi commented 10 years ago

Great. :+1: for alias pretty to :basename/index:html