|
| 1 | +--- |
| 2 | +slug: how-it-works |
| 3 | +title: Learn How Docusaurus Works |
| 4 | +authors: [personX] |
| 5 | +tags: [dhub, docusaurus, features] |
| 6 | +--- |
| 7 | + |
| 8 | +# Learn How Docusaurus Works |
| 9 | + |
| 10 | +This page is your gateway to understanding the essential features that make your blog tick. Get ready to explore the key elements that make Docusaurus a powerful tool for bloggers. |
| 11 | + |
| 12 | +### Framework |
| 13 | + |
| 14 | +[Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog). Simply add Markdown files (or folders) to the `blog` directory. The blog post date can be extracted from filenames, such as: |
| 15 | + |
| 16 | +- `2024-01-21.md` |
| 17 | +- `2024-01-21-how-it-works/index.md` |
| 18 | + |
| 19 | +### Page structure |
| 20 | + |
| 21 | +Docusaurus relies on _frontmatter variables_ to generate the blog post page. Instead of using the Heading-1 level title from the content, it extracts information from these variables: |
| 22 | + |
| 23 | +``` |
| 24 | +slug: page-url-slug |
| 25 | +title: The title Docusaurus uses to show in a page |
| 26 | +authors: [ceo, arijus] |
| 27 | +tags: [any, words, here, become, tags] |
| 28 | +``` |
| 29 | + |
| 30 | +Understanding this structure ensures a cohesive layout for your blog pages, allowing for a personalized and organized reader experience. |
| 31 | + |
| 32 | +### Images |
| 33 | + |
| 34 | +Explore two ways to add visuals to your blog: |
| 35 | + |
| 36 | +1. **Centralized Folder** |
| 37 | + |
| 38 | + Keep your images in a centralized folder. Upload them to `/static/img/`: |
| 39 | + |
| 40 | + [](https://unsplash.com/photos/shallow-focus-photography-of-gravels-zwjSCTItiZU) |
| 41 | + |
| 42 | +2. **Next to the Post File** |
| 43 | + |
| 44 | + Place your images next to the post file. For example, `plants.png` can be stored next to the `index.md` file in the `2024-01-20-how-it-works` folder:[](https://unsplash.com/photos/green-leaf-plants-xljtGZ2-P3Y) |
| 45 | + |
| 46 | +## Truncate |
| 47 | + |
| 48 | +Limit the size of your blog posts in the list view using a `<!-- truncate -->` comment. In the Dhub editor, add it as an **embedded MDX** code block from "/" components menu: |
| 49 | + |
| 50 | +<!--truncate--> |
| 51 | + |
| 52 | +## React components |
| 53 | + |
| 54 | +Docusaurus supports interactive components as part of the post's content. For example, if you insert this code block in Dhub's **embedded MDX** component: |
| 55 | + |
| 56 | +```js |
| 57 | +<button onClick={() => alert('button clicked!')}>Click me!</button>Tags |
| 58 | +``` |
| 59 | + |
| 60 | +In the published site, it will show this element: |
| 61 | + |
| 62 | +```mdx-code-block |
| 63 | +<button onClick={() => alert('button clicked!')}>Click me!</button> |
| 64 | +``` |
| 65 | + |
| 66 | +## Tags |
| 67 | + |
| 68 | +Tagging system enhances the organization of your posts, making it easy for readers to explore content based on their interests. |
| 69 | + |
| 70 | +Create new tags by adding them as _frontmatter variables_ at the start of the file: |
| 71 | + |
| 72 | +``` |
| 73 | +tags: [tag 1, tag 2, tag 3] |
| 74 | +``` |
| 75 | + |
| 76 | +## Authors |
| 77 | + |
| 78 | +Understand how authors are managed through the `blog/authors.yml` file, ensuring proper attribution to content creators. |
| 79 | + |
| 80 | +:::note |
| 81 | + |
| 82 | +At the moment, Dhub editor doesn't support opening this file; it has to be configured outside the Dhub editor. |
| 83 | + |
| 84 | +::: |
| 85 | + |
| 86 | +Learn about the `authors.yml` file structure at Docusaurus documentation: [Docusaurus Blog Documentation - Global Authors.](https://docusaurus.io/docs/blog#global-authors) |
0 commit comments