为Discourse撰写高效的文档

:information_source: Discourse documentation is currently being reviewed and edited to align with this style guide. Not all documentation topics currently match up to this - we are working toward that as quickly as possible.

This is considered a living document that guides how Discourse documentation is written and formatted. This topic will be kept up to date as needed. If you are in doubt about any of the principles here, please post on the topic to discuss specifics.

The guiding principle behind this documentation style guide is to consider your readers and their needs when writing documentation - what do they want to accomplish? What is your goal for providing the content?

:eyes: Quick checklist when implementing the style guide:

  1. Meta block is present and correct
  2. Title is action-oriented
  3. All titles use sentence case
  4. Correct tags and categories are used
  5. Document is structured logically

When completing a document, review it to make sure all of those criteria are met.

Please take note of these text formatting guidelines:


Meta information

  • Document should belong to one and only one of the following categories:
    • Using Discourse
      • General user guides for non-administrative tasks
    • Site Management
      • Settings, plugins, content, and general site administration
    • Integrations
      • Guides for integrating other platforms with Discourse
    • Hosted Customers
      • Guides that are only relevant to hosted customers
    • Self-hosting
      • Guides that are only relevant to self-hosted sites
    • Developer Guides
      • Technical guides for developing on top of Discourse, including creating themes, theme components, and plugins
    • Contributing
      • Guides for contributing to the Discourse open-source project
  • Document should belong to one and only one of the following tags / document types:
    • #how-to
    • #explanation
    • #reference
    • #tutorial
  • Document may have any other applicable tags, with an absolute maximum of 5 tags on a single document

Meta block

All documents must have a block at the top that includes a short explanation of what the document is about as well as any additional relevant meta information, like what the user level requirements are, whether console access is required, or anything else. This will be formatted in a blockquote without a heading over it. Heres an example of what this must look like:

:bookmark: This is a guide for describing all available hidden site settings, how to enable them, and why you might want to adjust them.

:person_raising_hand: Required user level: Administrator

:computer: Console access required

Titles and headings

  • Make document titles action-oriented
    • Incorrect: “How to enable automatic titles for chat threads”
    • Correct: “Enabling automatic titles for chat threads”
  • Document titles should not be too long
  • For ‘how-to’ topics, make the title goal oriented
  • All titles must be specific and unique
  • Do not use punctuation or special characters in document titles, other than commas
  • Do not include emoji in document titles
  • Use sentence case for titles and headings - that means only the first word starts with a capital letter, along with proper nouns and any other words that would normally be capitalised
  • Do not use ampersands (&) in headings, rather use the full word (“and”)

General writing guidelines, tone, and grammar

  • Use second-person voice when referring to people reading the document - i.e. use “you”, not “we”
  • Use active voice as much as possible
    • Incorrect: “the button should be clicked”
    • Correct: “click the button”
  • Define acronyms and abbreviations when first used, if necessary provide an external link that provides more information
  • Use short sentences, and break up text using shorter paragraphs, headings, and lists
  • You can use **bold** and *italics* to emphasise key phrases or words, but don’t overuse them
  • Avoid using jargon or technical terms without explanations - if in doubt, err on the side of explaining
  • Use screenshots when describing a visual interface, such as a UI element
  • Don’t document or attempt to disclose future Discourse features, products, or services unless explicitly permitted
  • Use transition words such as therefore, although, and furthermore.
  • Use common contractions: it’s, you’ll, you’re, we’re, let’s
  • Infer timelessness in documentation - avoid words such as soon, new, now, latest, etc. that quickly become irrelevant
  • Don’t attribute human qualities to software or hardware
    • e.g. “If you pass an integer to this API, it will get angry and raise an error”
    • e.g. “Our friendly and ambitious AI bot will help solve all your problems”
  • When quoting text (including from the Discourse UI), use “quotation marks”
  • When quoting a URL, use backticks
  • When using an example domain use discourse.example.com
  • If it would be useful, you can use emojis at the start of a paragraph to highlight it. Do not use more than two or three of these in a single topic. Some example emojis you can use:
    • :information_source: - An informative note
    • :mega: - Announcement or notice
    • :warning: - A warning message
    • :exclamation: - Very important information
  • Avoid:
    • Unnecessary metaphors or humour
    • Cultural and regional references
    • Dictating or ordering procedures in a condescending tone - e.g. You must click Publish or You need to click Publish
    • Being overly polite. For example, Please click Publish
    • Using exclamation points unless absolutely needed
    • Capitalizing words where it is unnecessary
    • Excess use of the same phrases and pronouns

For end user documentation:
Maintain a friendly, informal tone, with a focus on being clear and concise in a knowledgeable manner. Get to the point promptly. Explain technical terms, but be careful not to be condescending. To ensure clarity, start by briefly specifying the context of the current topic.

For developer and technical documentation:
Maintain a direct and precise tone. Use the same tone you would for user documentation, but you can assume a higher level of technical knowledge in your readers.

Structure

  • Get to the point fast - lead with what’s most important
  • Include important keywords early in the document
  • Make reader choices and next steps obvious
  • Always use light markup to write documentation (This is already built into Discourse with Markdown-it).
  • Organize your documentation in a logical flow - start with an overview, followed by detailed sections, and a summary or conclusion if applicable
  • Use headings and subheadings to structure your content, making it easier for readers to scan and find specific information - use descending hierarchy in headings, starting with h2, and don’t skip levels
  • Provide links to related topics or sections within your documentation - this helps users find additional information without unnecessary searches

Links

  • Use meaningful text in links
    • Incorrect: “Click here to read the guide”
    • Correct: “Read the guide
  • Unless the format of the URL is important or instructive, don’t use a URL as link text - instead, use the page title or a description of the page
  • Link to external sites and sources instead of quoting or rewriting existing documentation
  • Ensure that the sites you link to are of high standard and quality
  • If the link downloads a file, explicitly mention it - also indicate the type of file being downloaded and a rough estimate of the file size

Code in documentation

  • Use block code with language-specific syntax highlighting when possible for large code examples
  • If it is not already self-explanatory, introduce a code example with an introductory sentence that initiates the example that follows - when in doubt, err on the side of explaining
  • Code examples should follow the best practices for writing code for the relevant coding language
  • Use inline code for expressing basic code attributes or when a full code block is not necessary, such as:
    • Attribute names and values
    • Class names
    • Command-line utility names
    • Data types
    • Environment variable names
    • Filenames, filename extensions, and paths
    • Folders and directories
    • HTTP verbs, status codes, and content-type values
    • Query parameter names and values
    • Text input
  • When you use a placeholder in code examples, commands, or other text, including an explanation for what the placeholder represents
    • Write an explanation for the first time you use the placeholder; if there are multiple placeholders or steps after the first use of that placeholder, you can explain the placeholder again
  • Provide an easy way for users or developers to copy and run code.
    • Show expected output, either in a separate section after the code example or by using code comments within the code example
  • Write secure code - never hard-code passwords, API Keys, or secure information in code

Procedures and step-by-step guides

  • Format procedures consistently, so readers can find them easily by scanning
  • Use a separate numbered entry for each step
  • Include actions that finalize a step, such as OK or Apply buttons
  • If the instruction appears in the same UI where the action occurs, it’s usually not necessary to provide location details
  • If you need to make sure the reader begins in the right place, provide a brief phrase at the beginning of the step

Accessibility and inclusivity

  • Use screenshots, diagrams, or videos where they add value, particularly for explaining complex steps or showing parts of an interface
  • Images should be used to back up text information, not replace it
  • Always use alt attributes for images
  • Always provide captions or transcripts for videos
  • Only use GIFs if you can fully explain the content in text
  • Choose simple images and crop extraneous detail
  • Use plain language and avoid figures of speech or idioms that might not be universally understood
  • Consider that your document will be used on a multitude of devices
  • Use gender-neutral language. Don’t use he, him, his, she, her, or hers while referencing people - to write around pronouns, you can:
    • Rewrite using the second person (you)
    • Rewrite the sentence to have a plural noun and pronoun
    • Use the words person or individual
    • Use articles the, an, or a instead of a pronoun
    • Use a plural pronoun such as they, their, or them, even if it references a single individual
  • When you’re writing about a real person, use the pronouns that person prefers
  • Be inclusive of gender identity, race, culture, religion, ability, age, sexual orientation, and socioeconomic class - include a wide variety of professions, cultures, educational settings, locales, and economic settings in examples
  • Avoid politicised content - in cases where political content needs to be included, remain neutral
  • Don’t make any generalisations about people, countries, and cultures, not even positive or neutral generalisations
  • Don’t write prejudiced and discriminatory content against any communities, especially minorities
  • Avoid qualitative terms related to historical events
  • Avoid using terms and metaphors associated with violence and military actions

Last edited by @hugh 2024-09-03T11:02:51Z

Last checked by @hugh 2025-03-10T03:50:30Z

Check documentPerform check on document:
8 个赞

@hugh / @SaraDev
我在这里看到标题有些不一致。

我们有这些例子:

但接着我们又说:

如果我将“正确”的示例输入转换器,我会得到这个:

Enable Automatic Titles for Chat Threads

我们应该更新示例以匹配吗?

aside

如果由我决定,我会认为我们应该采用句子大小写,而且我不确定为什么我们当前的帖子标题中“Chat Threads”是大写的,所以我个人更希望看到这个:

Enable automatic titles for chat threads

但最终一致性更重要,我将假设你们有充分的理由选择当前的建议。

1 个赞

这是一个很好的发现——我之前没有想到这一点,但很容易更新。然而:

标题大写规范是我的决定,因为我觉得它通常看起来更简洁、更专业。我认为这很大程度上是我的主观意见,因为 GoogleMicrosoft 都建议在文档标题中使用句首字母大写。我找到的其他网站也建议使用句首字母大写,所以我将撤销此更改并更新那里的大小写要求。

3 个赞

我也注意到他们建议对标题 章节名都使用句子首字母大写。(我和您在同一个团队)。

看起来我们目前没有明确我们对章节名的偏好。我们顺便也加上吧。

1 个赞

同意 - 我会在这里添加它来明确指定。

1 个赞

好的,既然我状态这么好……

我喜欢我们这样说:

但在指南中,我们目前有这个例子:

我的看法是,在这里大写“隐藏网站设置”是不必要的。(诉诸权威

2 个赞

我感谢你的申诉 :smile:

是的,这是一个很好的观点——那个例子是从一份真实文件中提取的,我们在其中使用了现有文档的标题来描述它,由于该文档使用了标题大小写,因此引用也使用了标题大小写。随着从标题大小写更改为句子大小写,该引用也应更新。

1 个赞

根据上述对话,我对这份风格指南进行了一些修改。

  • 将主题标题更改为句子大小写
  • 将标题更改为句子大小写
  • 删除了不必要的资本化(Syntax)
  • 将标题中的和号 (&) 替换为“and”
  • 将标题中的斜杠 (/) 替换为逗号或连词

最后两项更改并未进行讨论——如果它们看起来多余或与指南不符,请告知我(或者,我们是否应在指南中捕获这些指南)。

2 个赞

我喜欢最后两个——它们绝对符合指南的精神,并且值得包含在指南本身中。我现在就添加它们。

1 个赞

我假设用于标记其他语言文档的标志是例外。

1 个赞

除了避免使用习语外,我一直避免在文档中使用缩略语。我认为这会使非英语/非西方读者更难理解。英语是一种奇怪的语言。

而且?

在某个时候,我们(可能是我)开始使用内联代码来引用站点设置。例如:“启用 discourse connect 站点设置。”这可能是正确的方法,但感觉有点开发人员风格。

也许值得使用一个一致的占位符名称来指代 Discourse 站点。比如 discourse.example.com?这里有一些文档引用 Discourse 站点为 sitename.com。这真的让我很困惑。


一些通用的写作建议:像目标受众的成员一样阅读你写的内容(看看缩略语有多么棘手)。确保你对受众先验知识的假设是合理的。

我很感激不再有大量文档主题归属于我,但将 Discourse 作为 所有 团队文档主题的作者感觉有点冷淡。

让我重新找回写作乐趣的是这个建议:寻找方法将你的一部分融入你所写的任何内容中。可以是任何东西,你的语气、你的爱好,任何东西……这与这里推荐的做法有点相反。

6 个赞

嘿,Simon! :blob_wave:

我本来想看看会发生什么,但嗯,我和你的看法一样,我尽量避免使用缩略语。

哈哈,是的……我不会在文档中使用这些词,以免暴露我的 :face_with_monocle:

绝对是:Example Domains

这就是我想来讨论的重点! :smiley:

我们对此进行了很多来回的讨论,很高兴看到它默认包含在风格指南中。

我认为这很重要,原因如下:编写文档需要尽可能地让我们的社区成员都能访问,包括(尤其是?)我们的 Discourse 团队成员。

Discourse 是一个社交、讨论软件。而有些文档实际上是一个持续的对话。如果我分享关于如何为我的社区成员入职的实践,我希望自己被呈现为该主题的“所有者”,这样我就可以回答问题并扩展该主题。

另一方面,如果客户询问我们从未解释过的功能,我希望能够使用风格指南并编写有用的、通用的文档,我认为成为主题所有者会阻碍发布。

另外,如果我们要在 Discourse 之外编写文档(集成或从代码注释生成等),拥有一个“文档用户”可能更容易作为实现细节。 :thinking:

我不认为本指南会阻止人们注入他们的声音和个性,并进行讨论。但如果它能帮助更多的人开始文档编写实践,而他们否则不会这样做(然后我们可以鼓励他们变得更具个性!),那就太好了! :smiley:

3 个赞

在有本地化文档的原生处理方式之前,我认为在标题前加上标志是处理它的最实用方法,并且是该指南的一个合理例外。

我认为这类事情有不同的意见和偏好,但对于这个风格指南,我们遵循公认的行业规范。再次强调,GoogleMicrosoft 的指南都同意使用常见的缩写更好。

话虽如此,我确实读过一些帖子建议使用否定缩写(如“can’t”)可能会让非英语母语者更难理解。我们将对此进行更深入的研究,并在必要时相应地更新风格指南。

我已经删除了那个例子! :smile:

是的——这很常见(不仅在 Discourse 中),但我同意这并不完全正确。使用引号会更好,所以我认为我会在风格指南中明确这一点。

这是一个很好的观点——我会在风格指南中加入这一点!

感谢您的反馈!@maiki 在上面提出了一些很好的观点,我同意他所说的。我想补充的是,我们已将官方文档切换为由 @Discourse 作为作者的原因之一是,为了让读者,特别是第一次接触文档的读者,感受到更大的权威性。这也是整个风格指南的初衷。

任何撰写文档的人当然仍然可以在他们的写作中注入个性,并且关于单个文档主题的讨论也不会消失,所以这总是一个让事情更具个性化的地方。

非常感谢所有这些反馈 :slight_smile:

2 个赞

关于指南中的元信息块。虽然指南规定文档主题需要一个元信息块,但并非所有主题都有 [1],而且它们在这里并不总是保持一致,以下是我找到的一些指南中的示例。

:person_raising_hand: 所需用户级别:任何用户”

:person_raising_hand: 所需用户级别:所有用户”

:person_raising_hand: 所需用户级别:任何用户”

个人而言,我更喜欢“所有用户”。

在收集一些反馈之前,我不想随意更改主题中的内容 :smiley:


  1. 也许这取决于主题的上下文? ↩︎

4 个赞

所有的 @Discourse 文档都在处理中,希望最终都能统一 (:crossed_fingers:)。不过关于不一致这一点说得很好。我不确定最终会选择哪一个,但我们一定会确保选定一个并坚持使用。:slight_smile:

4 个赞

我还应该补充一点,对于任何你看到包含新信息块的内容,都意味着它们已经通过了“第一阶段”并进入了审查阶段——所以如果你读到某个内容并认为“那不对”或“缺少一些信息”,并且你很慷慨愿意提供一些反馈,请在帖子中添加你的想法。:heart: :slight_smile:

5 个赞

顶部的必需用户级别信息有什么作用?我以为它会提供有关文档是否与我相关的信息。这样我就可以阅读它并决定“我不是 xxx,所以不相关”。
但似乎它的用途不同,例如,TL3 以下的用户可以编辑维基,所以它也与其他用户相关。

3 个赞

感谢您指出这一点,@Moin - 该主题已更新,以纠正所需的用户级别。

您对该信息用途的理解是正确的 - 它应该说明什么用户级别或类型能够执行文档中所述的操作。

1 个赞