如何将类别或标签添加到Svelte/Sapper降价网站? [英] How do I add categories or tags to a Svelte/Sapper markdown site?

查看:138
本文介绍了如何将类别或标签添加到Svelte/Sapper降价网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sapper/Svelte:如何添加降价文件?以帮助将来的搜索者:

Forking this question off from Sapper/Svelte: How do I add markdown files? to help future searchers:

我看到所有帖子都在顶级域Ex www.example.com/post1www.example.com/post2之后紧接一个链接.但是,如果有人使用模板要对帖子进行分类怎么办.例如www.example.com/svelte-posts/post1www.example.com/vuejs-posts/post1

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. Ex www.example.com/svelte-posts/post1, www.example.com/vuejs-posts/post1

推荐答案

如果您希望使用传统的WordPress样式的类别,可以将其添加到帖子的markdown前端问题中(

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.

但是,如果您提前知道的类别数量有限,并且您希望URL名称中的类别在帖子名称之前,那么尽管有一定的时间限制,但拥有单独的博客/帖子文件夹可能会更简单并使用 Svelte网站使用blog文件夹的方式.但是,如果您希望按传统的时间顺序索引所有类别的所有帖子,则此方法将无法正常工作,因此,如果您确实希望使用上面的前端问题方法,并且不必担心单个帖子的URL.

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.

根据我的经验,标签几乎总是比类别更好,因为您可以添加任意数量的标签.如果您写了一篇比较Svelte和Vue的文章怎么办?为什么不在两者中都出现呢?然后,您需要标记非类别. WordPress的历史由来已久,令人困惑,我认为他们最终使类别的行为像标签一样,因为他们厌倦了在需要标签和抱怨时与使用类别的人打交道.

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.

这篇关于如何将类别或标签添加到Svelte/Sapper降价网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆