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.

Blog Mode: Disable or modify the date prefixes `/blog/2020/08/01/title-slug`.

See original GitHub issue

🚀 Feature

For blog mode in Docusaurus V2, there should be a clean way to turn off the calendar date section within the URL path for each blog post, enabling more creative documentation use cases. In our own case we’ve built a “help center” (knowledge base) that would benefit from disabling the path prefix.

example.com/blog/2020/08/18/title-slug ==> example.com/blog/title-slug

Have you read the [Contributing Guidelines on issues]

Yes

Motivation

See help.getwisdom.io for a live example. example.com/2020/08/18/title-slug ==> example.com/title-slug

Pitch

Docusaurus has a great blog framework with a tagging system and related tag list pages (/tags/) that in some ways make it a more powerful documentation approach to using docs with a sidebar. We are using the “blog mode” for Help Center like documentation, however each blog entry has a calendar entry time that doesn’t provide benefit:

  1. Aesthetics are poor in this case
  2. Semantics are not relevant, given that for us, these posts should be frequently updated (evergreen).

Currently, saving a markdown file without the filename date prefix appears to just default to UTC date instead of no date within the URL path.

Candidate Interfaces:

Possible Interfaces:

  1. string path_prefix: string prefix.
    • null defaulting to current date /blog/2020/08/01/title-slug
    • '' empty string produces no prefix (special case to not produce /blog//title-slug)
    • string1/string2 produces /blog/string1/string2/title-slug
  2. boolean path_prefix: Config to disable URL path prefix (currently calendar date)
  3. function in docusaurus.config.js that sets the string prefix for each blog article (blog) => 'level1/level2';.
  4. Stop defaulting to UTC time if the file name is not prefixed with date.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
slorbercommented, Aug 12, 2020

Yes we should:

  • rename id to slug (add a warning for users using frontmatter.id)
  • document slug frontmatter
  • fix the date parsing logic that use current date as a default pathname prefix when filename is test.mdx: it should just lead to /blog/test unless user is using slug frontmatter

Thanks

1reaction
slorbercommented, Aug 11, 2020

Yes you are right we need a way to have better control of blog slugs.

I tried this:

image

And the URL was this: http://localhost:3000/blog/2020/08/11/heyyy. In such case we’d rather simply not adding the date to the URL at all.

Using markdown files without dates in filenames should be supported and not produce weird issues likes this.

We need a retrocompatible solution, and I’d be fine with 2 options:

  • frontmatter slug
  • boolean option to remove the date from the URL, and opt-out of this legacy behavior (not useful to provide custom path prefix, because there’s already a routeBasePath option anyway…)

Note: when using slugs, we should not prefix the slug of the user with a date. If they wants a date, they’ll add it to the slug.

In the long term we should encourage users to only use slugs and move out of this legacy url scheme

Someone wants to work on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I add/remove the date and time on my blog posts?
To add/remove the date and time on your blog posts, select the Blog Platform tile.Toggle the Display Date/Time button to "On" to display...
Read more >
How to Easily Remove the Date From WordPress Post?
Select the category for which you want to remove the date. Click on Save all changes button. Now when you check the selected...
Read more >
How to enable/disable a prefix/suffix on Android devices?
For a prefix/suffix to be enabled/disabled the following steps are recommended: Settings; Scanning; Internal Scanner; Default Profile ...
Read more >
How to disable noweb prefix lines? - Emacs Stack Exchange
There is another workaround: remove newlines from the referenced code block. According to the Org manual. Since this change does not affect ...
Read more >
prefix-65-127-disable | Junos OS - Juniper Networks
The maximum default value for LPM entries is 16000 IPv6 prefixes of all ... lpm-profile prefix-65-127-disable [edit] user@host# commit configuration check ...
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