tutorial05.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Tutorial Part 5: Creating a Blog
  2. ================================
  3. We want to add a blog to our site, so let's look at Article Pages.
  4. Adding articles to the site
  5. ---------------------------
  6. Article pages are child pages (also known as sub-pages) of an **Article Landing Page**. This
  7. is important because sub-pages can be accessed by the parent page. Let's look at this in action.
  8. .. note::
  9. We are going to use the "What's Happening at CRX-Pharma" page created in part 02 for our blog.
  10. Blogs are **Article Landing Pages** in Wagtail-CRX and are used interchangeably in this tutorial.
  11. Go to **Pages > Home** in wagtail admin. This screen will allow you to create child pages as seen in part 02 of the tutorial.
  12. Ours looks like this:
  13. .. figure:: images/tut05/blog_start.jpeg
  14. :alt: Screen for adding pages under the Home page.
  15. The admin screen for adding pages under the Home page sorted by last updated. Your's may look different depending on what you updated last.
  16. You should see the Article Landing with titled "What's New at CRX-Pharma". Hover over it to reveal more options.
  17. These options include: **Edit, View Live, Add child page,** and **More**. If you click on **More** you'll see a drop down menu
  18. with **Move, Copy, Delete, Unpublish, and History**.
  19. * **Move** allows you to change where that page is in site's tree structure.
  20. * **Copy** will make a copy of the page.
  21. * **Delete** removes the page from the project.
  22. * **Unpublish** will keep the page but it will no longer be accessible live.
  23. * **History** allows you to see changes made to the page.
  24. For now, We want to add a few posts, so select **Add Child Page**. This will
  25. take you to the Article page type for editing! Seen here:
  26. .. figure:: images/tut05/new_article.jpeg
  27. :alt: A fresh article page in edit mode.
  28. The edit screen for an article page.
  29. The anatomy of an Article Page
  30. ------------------------------
  31. The Article Page has several built-in fields to make it easy to publish an article, or blog as in our
  32. case. We will want to fill in the following:
  33. * **Title** - Title of the article or blog
  34. * **Cover Image** - Not required but can add interest to your page
  35. * **Caption** - The sub-title for the article or blog
  36. * **Publication Info** - Here we add the author, the display name for the author if different, and the Publication date
  37. * **Body** - Content for our article or blog
  38. Let's write a short blog about a fictitious vaccine that CRX-Pharma created. We added `this as our cover image <https://pixabay.com/illustrations/pill-capsule-medicine-medical-1884775/>`_ ,
  39. then filled out the the rest of the fields for our page.
  40. What our editor looks like:
  41. .. figure:: images/tut05/blog_editor.jpeg
  42. :alt: The edit screen for our first blog post.
  43. The edit screen for our first blog post.
  44. Now publish it and see what it looks like!
  45. .. figure:: images/tut05/blog_preview.jpeg
  46. :alt: Our first published blog post.
  47. Our first published blog post.
  48. Add a few more blog posts to get some practice, then we will return to our Blog landing page.
  49. .. figure:: images/tut05/blog_editor2.jpeg
  50. :alt: Admin view to edit our pages.
  51. The admin view to edit our blog posts and our Blog landing page.
  52. Completing our Blog landing page
  53. --------------------------------
  54. On the admin page, we can select to edit the main Blog page. Click the **Edit** button that is under the "What' New at CRX-Pharma".
  55. Alternatively, you can find the Blog page in the Home page admin view or by clicking on Pages.
  56. Just like on the other pages, we can add a cover image and build the layout. Let's do that! We will use
  57. Responsive Grid Row and just one full-width column for an introduction. Then we will show you the different
  58. ways to display your sub-pages on the landing page.
  59. .. figure:: images/tut05/landing_page_editor.jpeg
  60. :alt: The edit screen showing our intro on Blog page
  61. The edit screen showing the introduction on our Blog landing page.
  62. Publish and see what happens!
  63. .. figure:: images/tut05/landing_page_preview.jpeg
  64. :alt: Our published Blog page
  65. The published Blog landing page.
  66. Whoa! The blog posts are already showing up! What is this magic? Well, remember that this is a parent page type
  67. and the blog posts were children of this page. The option to "show children" is already pre-selected in the edit mode
  68. for landing pages. Let's look at that now.
  69. Ways to display sub-pages on a landing page
  70. -------------------------------------------
  71. Go back into the editor for the Blog landing page. You should see the following tabs at the top:
  72. * **Content**
  73. * **Classify**
  74. * **Layout**
  75. * **SEO**
  76. * **Settings**
  77. We want the **Layout** tab. Click on that tab and you'll see this:
  78. .. figure:: images/tut05/landing_page_settings.jpeg
  79. :alt: The Layout tab for the Blog landing page
  80. The Layout tab for the Blog landing page.
  81. We are using the default template, different templates have different layouts for child pages. The sections titled
  82. **"Show Child Pages"** and **"Child Page Display"** contain the settings for whether or not
  83. the sub-pages (blogs in this case) are automatically pulled onto the page, how many
  84. of them to show, and what fields or pieces of them to show as a preview.
  85. .. note::
  86. The "Show Child Pages" setting in Layout is the simplest and easiest way to display
  87. your sub-pages on a landing page.
  88. But we said that there are other ways to do this! Well, yes, there are. De-select "Show Child Pages"
  89. in Layout so that we can try the other way of displaying your sub-pages. Then go back to the Content area.
  90. You can add more content below the Text block with our introduction, or make a new column for content, or start
  91. a new Responsive Grid Row to add a column with content.
  92. What we want to look at is the **Latest Pages** block. The Latest Pages block is extra powerful because you can access
  93. the sub-pages of any landing page on the site. You can look at it for now, but we are going to use the "Show Child Pages"
  94. in the **Layout** tab after all.
  95. Remember to re-select "Show Child Pages" in Layout before publishing it.