このガイドでは、Discourse のページ発行機能の使用方法について説明します。この機能により、スタッフユーザーはトピックをカスタムスタイリングが施されたスタンドアロンの静的ページに変換できます。利用規約やプライバシーポリシーのページなどがこれにあたります。
必要なユーザーレベル: スタッフ
Discourse での静的ページの公開
ページ発行機能により、スタッフユーザーはトピックからスタンドアロンの静的ページを作成できます。これは、利用規約やプライバシーポリシーのページを作成するプロセスと似ています。
概要
このドキュメントでは、以下について説明します。
- ページ発行の有効化
- トピックをページとして発行する
- トピックの発行を解除する
- 一般的な問題と解決策
- よくある質問 (FAQ)
- その他のリソース
ページ発行の有効化
管理>設定に移動します。ページ発行を有効にする設定を有効にします。
ログインが必要な場合にページ発行を有効にする
ユーザーがログインしていない場合でも公開されたページを表示できるようにするには:
管理>設定でshow_published_pages_login_required設定を有効にします。
トピックの発行
公開トピックの最初の投稿に移動し、省略記号アイコン (
...) を選択します。
レンチアイコンを選択します。
「ページ発行 (Page Publishing)」オプションを選択します。
モーダルダイアログが表示され、スラッグ(投稿タイトルから事前入力可能)を確認し、発行されたページの URL をプレビューできます。
ページ発行を許可するには、セキュアアップロード (secure upload) サイト設定を無効にする必要があります。
⋌small>:information_source: ホストされているサイトの場合、セキュアアップロードはエンタープライズプランに制限されています。
公開されたトピック
公開 (Public)オプションがチェックされている場合、public ラベルが表示されます。
公開されたトピックには、その発行設定へのアクセスを許可する通知がタイトルの下に表示されます。
公開されたページ
トピックの発行を解除する
通知の下にある
発行設定 (Publishing Settings)を選択します。
発行解除 (Unpublish) をクリックします
ページが発行解除されます。
一般的な問題と解決策
ログアウト時に公開されたページが表示されない
管理>設定でshow_published_pages_login_required設定が有効になっていることを確認してください。公開されたページに Discourse のヘッダーを追加する
現在、静的ページは最小限にすることを意図しており、標準の Discourse のヘッダーとフッターは含まれていません。
よくある質問 (FAQ)
FAQ ページや「概要」ページを公開できますか?
必要なコンテンツで新しいトピックを作成し、それをページとして発行できます。サイト設定内のリンクをこれらの新しいページに向けるように変更してください。
公開されたページの見た目をカスタマイズするにはどうすればよいですか?
HTML ドキュメントの構造と対応する CSS セレクターを使用して、
管理>カスタマイズ>テーマ>CSSの下でカスタムスタイルを適用します。その他のリソース
I still need to try this out first hand so the following may not be grounded in reality, but:
It strikes me that this permission model sets up a scenario where you always see two copies of the pages’ content – one in the relevant Discourse category, and one in the published pages themselves. This of course seems duplicative if you’re wanting to publish pages for the general population that is similar to, or identical to, your Discourse user base.
OTOH, if pages had the “world readable” flag available, you could then restrict who can see/edit them to a small group, and the only place the content would be available to other Discourse users would be in the published links themselves.
(I’m thinking of a use case of a “documentation site” here.)
Otherwise, I’m pretty excited to test things out!
Awesome stuff, and thanks again for listening to your users. I love the ‘lets make this better for us all’ vibe that Discourse has! We’ll make heavy use of this.
When discussing one use (patching up an install that went a bit awry), another user pointed out a remaining bit of icing that could do with going on the cake:
Hey, is there any way to include the ability to make /faq and /about public as well, as they are currently hidden in Login Required sites. We can of course use the existing functionality that you’ve just released for /faq by making our own, changing the link in settings, and explicitly linking to it. However, this is not pretty and the existing navigation to it remains hidden. We can’t do that at all for /about of course.
Something that would go nice with this feature is to make publications onebox-compatible such that people could easily share the content.
Please excuse my ignorance, as I am very much a beginner in the HTML/CSS space… however, how would we go about applying our theme colour choices to published pages. At its simplest, I’d like to use the dark background/white text to give the published pages the same darkmode experience as accessing our forums.
Is this already in the product, or do I need to play with HTML/CSS? If the latter, could anyone give me some pointers in the right direction? Thanks!
Can you make this a separate feature request please? This is not related to page publishing, as in I wouldn’t have to change anything related to page publishing to make it possible. I do agree it would be better if all these “static” pages could have more or less the same behaviour, but there are multiple solutions here (do nothing? add site settings? migrate these to page publishing?), so we might want to have a dedicated topic for this.
GTM not loaded on published pages? Would be nice.
Hmm that is a really good point.
Just trying to think of a solution here… would it work if type="text/javascript" and type="text/discourse-plugin" were treated differently? The API needs the latter, right?
Yes I think we already support having a text/javascript in the theme fields, so there are certainly solutions in this area.
That would be great.
So it’s currently impossible to have responsive published pages, and this site particularly wants
- images made available when sharing to public media, and
- responsive/resizing images displayed, especially on mobile–oh, mobile could just resize the image with CSS–that should work, right?
+1 for having the Discourse header in published pages. I’m missing my website logo, custom header links and beloved hamburger menu 
Another oddity: in posts, my lightboxed images open in a nice popup, whereas in published pages, they open in a new tab…
必要なのは、そのような機能を追加するテーマコンポーネントのセットだと思います。以前、この機能を使わなければならなかった最後のクライアントは、トピック作成者を削除したいと要望していました。これについては、人々のニーズに合致するものを推測するのは難しいと思います!
現在、公開ページに「シンプル」な(API を使用しない)JavaScript サポートを追加するための取り組みは進められていますか?それとも、近い将来から中期的にはこの計画は諦めるべきでしょうか?
このページに外部の非 Discourse JSON を表示することはできますか?ここでは PHP コードが使えず、Discourse が HTML の大部分を除去してしまうため、どのようにすればよいかわかりません。
公開されたページで問題が発生しています。コードブロックの内容をコピーするボタンが公開ページに表示されません。スクリーンショット: Screenshot by Lightshot
この問題を再現できますか?解決策はありますか?
@riking さん、ありがとうございます!
どうやら、テーマコンポーネントの header または footer にある「通常の」text/javascript は、公開されたページで実行されているようです。
ハッ!どうやら、テーマコンポーネントをページ公開と連携させるためのちょっと荒技な方法があるようです。
公開されたページにヘッダーやフッターを追加しようと考えているのですが、テーマコンポーネントを使うのが良さそうです。ただ、近い将来に壊れる可能性のあるものを無理やり実装するのは良くない気がします。
@riking さん、公開ページで header や footer 内の text/javascript タイプが機能しているのは意図しないものだったようですね。これは 修正 される予定ですか、それとも公開ページの拡張に 利用 される予定ですか?
DiscPage の作者である @syl さんは、Page Publishing 機能を使って DiscPage プラグインを再実装する可能性 について触れていました。@syl さん、まだそのご予定はありますか?@riking さん、両方の機能を統合する上で、最も抵抗の少ない道はどのようなものだと思いますか?
残念ながら、「Page Publishing」機能は私の要件を満たしません。これを利用するには、公開されたページが以下の条件を満たす必要があります:
- 通常の Discourse レイアウト内(利用規約やプライバシーポリシーと同様に、標準的な Discourse ヘッダー付き)に表示されること、
- 通常の(装飾された)トピックと同様にレンダリングされ、bbcode やプラグインをサポートすること。
その間、私はデフォルトのDiscourseカスタマイズ機能を使用しました:
- 追加された要素を特定します(例:
published-page-footer-linksCSSクラスを使用)。 - デフォルトではこの要素を非表示にし、公開ページでのみ表示するようにCSSをカスタマイズします。
- 要素を
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>











