问题
Forking this question off from Sapper/Svelte: How do I add markdown files? to help future searchers:
I see that all the posts will have a link right after the Top-Level Domain Ex
www.example.com/post1
,www.example.com/post2
. But what if someone using the template wants to categorize the posts. Exwww.example.com/svelte-posts/post1
,www.example.com/vuejs-posts/post1
回答1:
If you want traditional WordPress-style categories I would add that to the markdown front matter of the posts (Jekyll docs) and then create a category page template using dynamic parameters, with links to any categories in your individual post template as well.
However, if there are a limited number of categories you know ahead of time, and you want the category in the URL before the post name, it might be simpler, though limiting over time, to have separate blogs/folders of posts and use those the way the Svelte site uses the blog folder. This would not work well if you wanted a traditional chronological index of all of the posts from any category though, so if you did want that use the front matter approach above and don't worry about the URL for individual posts.
Also in my experience, tags are almost always better than categories, because you can add as many as you like. What if you wrote a post comparing Svelte and Vue? Why not have it appear in both? Then you want tags not categories. WordPress has a long, confusing history with this where I think they finally made categories behave like tags because they got sick of dealing with people using categories when they wanted tags and complaining.
来源:https://stackoverflow.com/questions/58674044/how-do-i-add-categories-or-tags-to-a-svelte-sapper-markdown-site