页面发布

:bookmark: 本指南涵盖了如何在 Discourse 上使用页面发布功能。此功能允许 Staff 用户将主题转换为具有自定义样式的独立静态页面。示例包括服务条款和隐私政策页面。

:person_raising_hand: 所需用户级别:Staff

在 Discourse 上发布静态页面

页面发布功能允许 Staff 用户从主题创建独立静态页面。这类似于创建服务条款或隐私政策页面的过程。

摘要

本文档将涵盖:

  • 启用页面发布
  • 将主题发布为页面
  • 取消发布主题
  • 常见问题及解决方案
  • 常见问题解答 (FAQs)
  • 附加资源

启用页面发布

  1. 导航至 Admin > Settings(管理 > 设置)。
  2. 激活 enable page publishing(启用页面发布)设置。
    Enable Page Publishing

登录时启用页面发布

若要使已发布的页面在用户未登录时可见:

  1. Admin > Settings(管理 > 设置)处激活 show_published_pages_login_required(需要登录才能显示已发布页面)设置。
    Show Published Pages

发布主题

  1. 转到公共主题的第一个帖子,然后选择省略号图标(…)。
    Ellipsis Menu

  2. 选择扳手图标。
    Wrench Icon

  3. 选择“Page Publishing”(页面发布)选项。

  4. 将出现一个模态对话框,允许您确认 slug(可从帖子标题预先填充)并预览已发布页面的 URL。

:warning: 要允许页面发布,必须禁用 secure upload(安全上传)站点设置。

:information_source: **对于托管站点,[安全上传仅限于企业版 (Enterprise plan)。](https://meta.discourse.org/t/secure-uploads/140017#enabling-secure-uploads-2)**

已发布的主题

已发布的页面

取消发布主题

  1. 在通知下方选择 Publishing Settings(发布设置)。

  2. 点击 Unpublish(取消发布)

  3. 主题已取消发布。

常见问题及解决方案

登出后无法看到已发布的页面

确保在 Admin > Settings(管理 > 设置)中激活了 show_published_pages_login_required 设置。

向已发布页面添加 Discourse 标题

目前,静态页面旨在保持最小化,不包含典型的 Discourse 标题和页脚。

常见问题解答 (FAQs)

我可以将 FAQ 或关于页面设为公开吗?

您可以创建一个包含所需内容的新主题并将其发布为页面。更改站点设置中的链接,使其指向这些新页面。

如何自定义已发布页面的外观?

使用 HTML 文档结构和相应的 CSS 选择器,在 Admin > Customize > Themes > CSS(管理 > 自定义 > 主题 > CSS)下应用自定义样式。

附加资源

118 个赞
Best landing page solution
ProCourse Static Pages
Using Discourse as a News Blog and Forum - Any Known Good Examples?
How to add a new page into the community? (Login isolated page)
Blog Post Styling
Is anyone here using their Discourse instance as their entire website?
How do I redirect urls or create new ones?
Discourse + CMS, which one?
Is there an upper limit to how many pages can be published?
Host HTML page on Discourse install
Integrating webpage to current forum
Open (anon) interaction with a forum
Shared Drafts: Allow staff to collaborate on posts before publishing
Is there any way to listen User login event using Theme component
How to share only few posts to public as links?
Open (anon) interaction with a forum
Create a "Docs" page like discource meta's
Invite people to reply to a topic without them needing to create an account
Allow anonymous users to view a topic?
What's the usage of "show published pages login required" setting?
How to add contact us page?
Embed my Discourse Forum as IFrame
Is there any way to restrict posting in a topic to members of a group, but allow all users to read the topic?
Order posts by Title
Edit Code
Published page not visible?
Inline Tooltips
Making the About and FAQ visible to anon
Allow published pages to be visible to anon
Customize login page
7 myths why a blog isn't needed in the discourse core
Landing Page
Customizing FAQs and Guidelines
ProCourse Static Pages
Can I use secure media and page publishing simultaneously in Discourse?
Publishing - how deep/good is fine-grained permisson control?
Publish Direct Messages
500 character ‘Reject Reason’ is too small a limit
How do I create a blank page within Discourse
How-to use Discourse for managing a collaborative newsletter?
Customize Login pop-up box?
Building a custom html page in discourse
Page for not-logged in users with a single topic displayed
Duplicate Terms of Service/Privacy Policy
Paid Groups
Help custom page?
Should Discourse make an effort to become the next best "CMS"
Is It Possible to Create Custom Pages in Discourse?
How to Enable Terms of Service and Privacy Policy Pages in Discourse?
Is It Possible to Create Custom Pages in Discourse?
Blank Pages Related Help
How do root level links work?
Creating custom pages like "About" and "FAQ"
Multi-factor authentication enforcement lock in without help
Can you create a custom landing page?
Static pages for things like guidelines?
Create a new text page option?
Change topic visibility in an admin category to public
Create a custom page with theme cli?
DiscoTOC - automatic table of contents
Adding a static web page
[Urgent] privacy policy page
How to make a website with Discourse
Generate static file in discourse
Discourse for Teams is here!
Category Previews
Public Static pages and Private Forums - possible?
Filter view for muted categories
Category Previews
How to hide a single topic from showing up in "latest"?
ProCourse Static Pages
Control the visibility of /faq and /about
[Question/Request] Featured image url for post
Custom Homepage for Groups
Embedding private discussions on a wordpress site
Table of Contents not working on Published Pages

我仍需亲自尝试一下,因此以下内容可能并非完全基于现实,但:

我觉得这个权限模型设定了一种场景,即你总是能看到页面内容的两个副本——一个在相关的 Discourse 分类中,另一个在已发布的页面本身。如果你希望为与 Discourse 用户群相似或相同的普通大众发布页面,这显然显得重复。

另一方面,如果页面拥有“世界可读”标志,你就可以将查看/编辑权限限制在一个小群体内,而其他 Discourse 用户只能通过已发布的链接访问内容。

(我想到的是“文档网站”这一用例。)

除此之外,我对测试这一功能感到非常兴奋!

8 个赞

太棒了,再次感谢你们倾听用户的反馈。我特别喜欢 Discourse 那种“让我们共同把这里变得更好”的氛围!我们会大量使用这项新功能。

在讨论其中一个用例(修复安装过程中出现的一些问题)时,另一位用户指出还有一个可以锦上添花的小细节:

请问,是否有可能让 /faq 和 /about 页面在“需要登录”的站点中也公开可见?目前这两个页面是隐藏的。当然,我们可以利用您刚刚发布的针对 /faq 的现有功能,自行创建页面,在设置中更改链接,并显式链接到它。但这并不美观,而且现有的导航链接仍然被隐藏。至于 /about 页面,我们则完全无法这样做。

9 个赞

与此功能相得益彰的是,使出版物支持 onebox 格式,这样人们就可以轻松分享相关内容。

15 个赞

请原谅我的无知,因为我在 HTML/CSS 领域还是个新手……不过,我们该如何将主题颜色选择应用到已发布的页面上呢?最简单的做法是,我希望使用深色背景/白色文字,让已发布页面拥有与访问论坛时相同的深色模式体验。

这已经是产品自带功能,还是需要我自行调整 HTML/CSS?如果是后者,能否有人给我一些方向上的指点?谢谢!

4 个赞

能否将此作为一个独立的功能请求提出?这与页面发布无关,因为我不需要更改任何与页面发布相关的内容即可实现该功能。我同意,如果所有这些“静态”页面都能拥有大致相同的行为会更好,但这里有多种解决方案(什么都不做?添加站点设置?将它们迁移到页面发布?),因此我们可能需要为此创建一个专门的主题。

8 个赞

已发布的页面上 GTM 未加载?那就太好了。

2 个赞

嗯,这确实是个很好的观点。

我正在思考一个解决方案……如果将 type="text/javascript"type="text/discourse-plugin" 区别对待,是否可行?API 需要后者,对吧?

5 个赞

是的,我认为我们已经支持在主题字段中使用 text/javascript,因此这方面肯定有解决方案。

7 个赞

那太好了。

1 个赞

因此,目前无法实现响应式发布的页面,而本网站特别需要:

  1. 在分享到公共媒体时提供图片;
  2. 显示响应式/可调整大小的图片,尤其是在移动设备上——哦,移动设备或许可以直接通过 CSS 调整图片大小——这应该可行,对吧?
6 个赞

+1 支持在发布页面中保留 Discourse 头部。我找不到我的网站标志、自定义头部链接和心爱的汉堡菜单了 :slight_smile:

另一个奇怪的现象:在帖子中,我的灯箱图片会在一个漂亮的弹窗中打开,而在发布页面中,它们却会在新标签页中打开…

7 个赞

我认为需要一组主题组件来实现这些功能。我上一个使用此功能的客户要求移除话题创建者。我认为很难猜测什么能满足人们在这方面的需求!

6 个赞

目前是否有正在进行的努力,为已发布的页面添加“简单”(非 API)的 JavaScript 支持?还是说我们应该在近中期放弃这一想法?

9 个赞

我能在这页面上显示外部的非 Discourse JSON 吗?因为我们无法在此使用 PHP 代码,而且 Discourse 会剥离大部分 HTML,所以我不知道该如何操作。

2 个赞

我遇到一个已发布页面的问题:代码块的复制按钮在已发布页面上不可见。截图:Screenshot by Lightshot

有人能复现这个问题吗?有什么解决方案吗?

2 个赞

感谢 @riking

确实,当 text/javascript 出现在主题组件的 headerfooter 中时,它会在已发布的页面上执行。

8 个赞

哈哈!看来有一种取巧的方法可以让某些主题组件与页面发布功能协同工作。

我正在研究为已发布的页面添加一些页眉/页脚,主题组件似乎是可行的方案。但实施一个可能在不久的将来就会失效的功能似乎不太妥当。

@riking,看起来在 headerfooter 中使用 text/javascript 类型并在已发布页面上生效似乎是无意的。这会被“修复”掉,还是会被“利用”来扩展已发布页面的功能?

DiscPage 的作者 @syl 提到了 利用页面发布功能重新实现 DiscPage 插件 的可能性。@syl,你还有这个打算吗?@riking,你认为整合这两项功能阻力最小的路径是什么?

7 个赞

不幸的是,“页面发布”功能无法满足我的需求。若要使用它,我需要发布的页面:

  1. 显示在正常的 Discourse 布局中,即带有标准的 Discourse 页眉(就像 服务条款隐私政策 那样),以及
  2. 像普通(带样式的)主题一样渲染,即支持 bbcode 和插件。
15 个赞

在此期间,我使用了 Discourse 默认的自定义功能:

  1. 识别新增的元素,例如通过 published-page-footer-links CSS 类。
  2. 自定义 CSS 以默认隐藏该元素,仅对已发布的页面显示。
  3. Footer 区域添加该元素。

2. 在 CSS 中添加:

/* 仅在已发布的页面上显示页脚链接 */
.published-page-footer-links { display: none; }
.published-page .published-page-footer-links { display: block;}

3. 在 Footer 中添加:

<nav class="published-page-footer-links">
大家好!这是已发布页面的页脚!
</nav>
8 个赞