着陆页博客 ✈️

Working, but no longer maintained [July 2022]

You can now use the Landing Pages Plugin to run a blog with Discourse :tada:. Set a category to be your blog, and the first post of every topic in that category will have its own blog page, and appear on a blog post list page.

Screen Shot 2021-05-13 at 5.04.18 PM

This project has been a joint effort between @meghna and myself. All of the nice design work is hers. If you like the design of this blog make sure to check our her Discourse Themes. Any bugs you find in the functionality are mine :slight_smile:

Get the code

GitHub-Mark-64px Landing Pages Plugin
GitHub-Mark-64px Blog Landing Pages
GitHub-Mark-64px Blog Landing Theme

See it in action

try.thepavilion.io/blog

Please note that all content on the blog and displayed in screenshots in this post is from The Conversation, and used under the Creative Commons License used by that site. All content belongs to its original authors and is used for demonstration purposes only.

How to set it up

Follow these steps in order

  1. Install the Landing Pages Plugin (how to install a plugin in Discourse).
  2. Install the Blog Landing Theme, (how to install a theme in Discourse).
  3. Set up the Blog Landing Pages as your landing pages repository.
  4. In the Landing Pages Administration UI change the category of the “Blog” page to whatever category you want to use to run your blog.

That’s it! The first post of every topic in that category will now be posts on your blog :slight_smile:

Restrict posting to contributors

You’ll probably want to restrict posting in that category to a group of blog contributors. If you’re not sure how to do that, here’s a quick guide

  1. Create a user group, e.g. “Contributors”, by going to /groups and clicking “New Group”
  2. Add users to the group (“Add Members” in the top right)
  3. In the blog category “Security” settings remove the “Create” permission from “Everyone”, and add your Contributors group

Now only your contributors can post on your blog, but everyone can comment on posts.

What makes this different from other blog solutions?

There’s some great existing solutions to running a blog inside or alongside Discourse, including

This is a bit different as it’s an entirely seperate set of pages that are not part of the Discourse client app, but it still uses the same server. This gives you a few advantages over running a seperate blog (e.g. on Wordpress), or using a Discourse category directly (e.g. with a theme component), including

  • You can create content and let users reply in Discourse, but have a dedicated blog environment for reading and sharing. Readers of your blog will feel like they’re reading a blog instead of a forum post.
  • You have a single user account system (Discourse’s)
  • You can use Discourse groups to restrict access to the blog
  • You can make Discourse posts appear as comments on your blog with no additional setup
  • You get nice responsive blog theme out of the box
  • You only have to set up, and pay for, one server
  • The blog doesn’t need to load your forum to work, so it can load quickly
  • You can easily keep your blog pages (and theme) in version control
  • You get a nicely formatted New Blog Post notification email (see below)
  • You can easily manage it alongside any other landing pages you need using the Landing Pages Plugin.

However, while the Blog Landing Pages have some clear advantages, they aren’t going to be the best community blog solution for everyone. You should test out the different solutions and see which one works for you.

What does it mean to “Subscribe” to the blog?

If you’re logged in and click the “Subscribe” button you’ll see a modal (if you’re logged out you’ll be redirected to Discourse login)

If you’ve checked the box next to “Subscribe to [site name]'s posts” and submitted the form, you’ll automatically be set to “Watching First Post” for the blog category. That means you’ll get an email notification every time there’s a new post in that category, like you would if you were subscribed to a blog!

You can also set your notifications for the blog category to “Watching First Post” in the normal way (in Discourse) and that will have the same effect. “Watching” the category (were you get an email for every post, including replies), also counts as being subscribed.

The email notifications for a blog category are a bit special. Firstly, unless you made the post yourself, you’ll always get an email notification if you’re subscribed, even if you visited the site recently. Secondly, they’re designed to look like a blog post email

We plan to allow a site admin to edit the blog post email html in the Landing Pages Administration UI in the near future. Note that if you’re “Watching” the blog category, only the email notification for the first post in each topic will be different. Notifications for replies will look like normal Discourse notifications.

Beyond blogging

You can use the functionality described above to create a set of landing pages for any content, like how Wordpress is a blogging engine that you can use for displaying other (non-blog) types of content. You could use a category to manage a set of products, places or people, and automatically get both a landing page and a discussion topic for the content, just by making a single post in Discourse.

Any developer who knows a bit of Ruby on Rails could achieve any of those additional use cases using this system. You don’t need to know how Discourse works. As these blog pages are part of the landing pages plugin, you also get access to all the existing templates in that plugin, including contact forms, header, footer, topic lists and user profiles. You can read more about these templates, and others, in the plugin documentation.

41 个赞

Looks great, good job! Is the Blog Landing Theme a requirement? Would it be possibel in that case to have it as a component (since those who already have another/customized theme might want to stick with it)?

2 个赞

The Blog Landing Pages, and the functionality in the Landing Pages Plugin they rely on, are both designed to work with any theme :slight_smile: You can customise this however you like.

It doesn’t need to be active on your Discourse site to work, it just needs to be installed, then selected in the relevant page in the Landing Pages Admin UI. This is what the theme settings look like on try.thepavilion.io (you can see the page settings in the OP)

3 个赞

Epic! Excited to try this out. Thanks for this :slight_smile:

2 个赞

:exploding_head:

This is really cool. Got me rethinking my entire approach. Thanks! :laughing:

2 个赞

This is great!

For customizing, should I fork the repo to input my site’s info? Or is there a better way to do that?

2 个赞

Thanks @sethm, yes the Blog Landing Theme and Blog Landing Pages are intended as templates, so you could:

  • import them directly into your instance as described above;
  • fork them; or
  • download them and modify them like you would with a template for Wordpress, Ghost etc.
3 个赞

是否有办法让部分 Discourse 内容公开显示(如本博客内容),而不是要求注册/登录?谢谢。

–Peter

1 个赞

嘿 Peter,是的,默认情况下 Discourse 中的内容是公开可见的。如果不是,则表示您启用了“需要登录”站点设置。然后,您可以使用特定于类别的权限(在类别设置中)来控制特定类别的可见性。您可以在上方看到类别特定访问设置的屏幕截图。

1 个赞

但是,我看不到特定于类别的访问设置的屏幕截图?

1 个赞

有什么帮助吗?
也许只有当我删除“需要登录”时,特定于类别的设置才会出现?
但除非我将类别设置为“公开”或“需要登录”,否则我不想删除它……
谢谢。

——彼得

1 个赞

您应该可以在类别页面的管理扳手(admin wrench)的“安全”(Security)选项卡中查看类别权限:

希望这能帮到您。:slightly_smiling_face:

2 个赞

啊!谢谢。
那么,将所有类别和当前用户设置为信任级别 2,并将我想要设为公开的新类别设置为信任级别 0,并更改“需要登录”设置,就能奏效吗?或者这个逻辑是错的?

——Peter

1 个赞

如果您希望博客类别对匿名用户和账户持有者都可见,那么您希望“所有人”组至少具有“查看”权限。

然后将其他类别设置为至少 trust_level_0,这样用户就需要拥有账户才能查看和互动这些类别中的主题。

1 个赞

谢谢,这奏效了。感谢您的帮助。

2 个赞

我需要一些帮助来理解这个插件。一方面,你说你可以

将一个类别设置为你的博客,该类别中每个主题的第一篇文章将拥有自己的博客页面,并出现在博客文章列表页面上。

另一方面

  1. 将博客登陆页面设置为你的登陆页面存储库。

我很困惑。我可以在没有 git 存储库和任何 *html.erb 文件的情况下,用我的 Discourse 帖子运行一个博客吗?

1 个赞

博客的内容是从 discourse 帖子中提取的。博客的布局由 html 文件处理,这些文件可能位于 Blog Landing Pages 存储库中。

此插件不像 Hugo 那样在标记语言中创建博客帖子。虽然将其与 Hugo 集成会很酷,但我们可以稍后尝试(cc @jumagura

3 个赞

我运行 Discourse 论坛已经几个月了,所以对它还比较陌生。我之前安装过一个插件,但今晚当我尝试安装 Landing Pages Plugin 时,在重建应用程序时遇到了错误,并且它无法启动。也许是兼容性或版本问题,但我不知道从哪里开始。有人能给我指点一下吗?我查看了日志,但看不出问题所在。

这是运行重建后结果的最后一部分:

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 364 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
fb680c9c3b46dcd068abe877ed4187c730351c10139cc3eda2a8b7202822bf07
saul@discourseonubuntu2004-s-1vcpu-2gb-intel-lon1-01:/var/discourse$
saul@discourseonubuntu2004-s-1vcpu-2gb-intel-lon1-01:/var/discourse$

感谢任何帮助。

1 个赞

有人能帮忙检查一下这个插件吗?我遇到了和上面那位用户一样的问题。在尝试构建它时,我收到了一些错误,显然自 2.9.0 beta 4 及更高版本以来它就坏了。

我可以提供一些日志,但如果创建者检查一个全新的 discourse 安装然后尝试构建它会更好,因为我在现有的 discourse 安装和全新的安装上都测试过,它总是构建失败。

我严格按照初始帖子中提供的步骤进行操作。

  1. 安装 Landing Pages Plugin (如何在 Discourse 中安装插件)
  2. 安装 Blog Landing Theme , (如何在 Discourse 中安装主题)
  3. Blog Landing Pages 设置为您的 landing pages repository
  4. 在 Landing Pages Administration UI 中,将“Blog”页面的类别更改为您要用于运行博客的任何类别。
1 个赞

我将在下周更新此插件以兼容最新的 Discourse

4 个赞