Это руководство посвящено использованию функции публикации страниц в Discourse. Она позволяет пользователям с правами Staff преобразовывать темы в отдельные статические страницы с пользовательским оформлением. Примеры включают страницы «Условия использования» и «Политика конфиденциальности».
Требуемый уровень доступа: Staff
Публикация статических страниц в Discourse
Функция публикации страниц позволяет пользователям с правами Staff создавать отдельные статические страницы на основе тем. Это аналогично процессу создания страниц «Условия использования» или «Политика конфиденциальности».
Краткое содержание
В этой документации рассматриваются следующие вопросы:
Включение функции публикации страниц
Публикация темы в виде страницы
Отмена публикации темы
Распространённые проблемы и их решения
Часто задаваемые вопросы (FAQ)
Дополнительные ресурсы
Включение функции публикации страниц
Перейдите в раздел Admin > Settings.
Активируйте настройку enable page publishing.
Включение публикации страниц при необходимости входа в систему
Чтобы опубликованные страницы были видны даже при отсутствии входа в систему:
Активируйте настройку show_published_pages_login_required в разделе Admin > Settings.
Публикация темы
Перейдите к первому сообщению публичной темы и выберите иконку с тремя точками (...).
Появится модальное окно, в котором вы сможете подтвердить slug (который может быть предварительно заполнен на основе заголовка сообщения) и просмотреть URL опубликованной страницы.
Невозможно увидеть опубликованные страницы при отсутствии входа в систему
Убедитесь, что настройка show_published_pages_login_required активирована в разделе Admin > Settings.
Добавление заголовка Discourse на опубликованные страницы
В настоящее время статические страницы предназначены для минималистичного отображения и не включают стандартные заголовок и подвал Discourse.
Часто задаваемые вопросы (FAQ)
Могу ли я сделать страницу FAQ или «О нас» публичной?
Вы можете создать новую тему с нужным содержимым и опубликовать её как страницу. Затем измените ссылки в настройках сайта, чтобы они указывали на эти новые страницы.
Как можно изменить внешний вид опубликованной страницы?
Используйте структуру HTML-документа и соответствующие CSS-селекторы для применения пользовательских стилей в разделе Admin > Customize > Themes > 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.)
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.
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.
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?
I think what’s needed is a set of theme components that add such. The last client I had to use this wanted the topic creator removed. I think it’s hard to guess what will meet people’s needs for this!
Are there currently any ongoing efforts for adding “simple” (non-API) Javascript support to published pages? Or should we forget about this near- to mid-term ?
Can i display external non-Discourse JSON on this page? Because we can’t use php code here and discourse strip most of html so i do not know how to do it…
I have a problem with a published page - the button to copy the content of the code block is not visible on a published page. Screenshot: Screenshot by Lightshot. I move the mouse over the block, but the button doesn’t appear. When logged in - everything works as usual - ok.
Ha! So it seems that there’s a hacky way to make some theme components work with page publishing.
I’m looking into adding some header/footer to the published pages, and theme components seem to be the way to go. But it seems bad to go on and implement something that would potentially break in the near future.
@riking, it looks like the text/javacript type in header or footer working on published pages was unintented. Is it going to be fixed or used to extend published pages?
Unfortunately, the “Page Publishing” feature doesn’t meet my needs. For me to use it, I would need published pages:
to be displayed within the normal Discourse layout, i.e. with the standard Discourse header (just like the Terms of Service and the Privacy Policy), and
to be rendered like normal (decorated) topics, i.e. supporting bbcode and plugins.
In the meantime I used the default Discourse customization facility:
Identify the added element, e.g., with a published-page-footer-links CSS class.
Customize CSS to hide this element by default and show it only for published pages
Add the element in the Footer space
2. In CSS, add:
/* Only show footer links on published pages */
.published-page-footer-links { display: none; }
.published-page .published-page-footer-links { display: block;}
3. in Footer, add:
<nav class="published-page-footer-links">
Hi there! This is the footer for published pages!
</nav>