tutorial01.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. Tutorial Part 1: Site Name, Logo, and Global Colors
  2. ===============================================================
  3. .. note::
  4. For this tutorial, we will assume the name of your project is ``mysite`` and you started using the ``pro`` template.
  5. After :doc:`install`, you are greeted with a bare-bones website.
  6. Let's start filling things out.
  7. Logging in
  8. ----------
  9. Navigate in your browser to http://localhost:8000/admin/ and log in with the username
  10. and password you created with the ``python manage.py createsuperuser`` command.
  11. .. figure:: images/tut01/login.jpeg
  12. :alt: Login Screen.
  13. The login Screen
  14. After logging in, you will be taken to the admin dashboard - also known as the "Wagtail Admin".
  15. .. figure:: images/tut01/admin.jpeg
  16. :alt: The admin dashboard.
  17. The admin dashboard.
  18. .. _site-name:
  19. Changing your site name
  20. -----------------------
  21. By default, the site name shows up in many different places, including page titles in the browser tab.
  22. To change the name, go to **Settings > Sites**, and click on the site that is there. Change the
  23. **Site name** setting and click "Save".
  24. .. note::
  25. There is also a ``WAGTAIL_SITE_NAME`` setting in the ``mysite/settings/base.py`` file. This is really
  26. only used for the login screen and on the main Wagtail Admin dashboard. The reason this setting exists
  27. is for use with multi-sites. For example, if you have a parent company that operates many separate
  28. brand websites within one CMS, then ``WAGTAIL_SITE_NAME`` would be the name of the parent company.
  29. For this website, Let's change the name to **Settings > Sites > Site name** to "CRX-Pharma".
  30. .. figure:: images/tut01/sitename.jpeg
  31. :alt: Changing the site name.
  32. Changing the site name.
  33. And edit ``mysite/settings/base.py`` by changing ``WAGTAIL_SITE_NAME`` as so::
  34. WAGTAIL_SITE_NAME = 'CRX-Pharma'
  35. .. figure:: images/tut01/sitename_vscode.jpg
  36. :alt: Changing the site name in base.py
  37. Changing the site name in base.py
  38. Now the admin dashboard, login page, and Home page (at http://localhost:8000/)
  39. will show "CRX-Pharma".
  40. .. figure:: images/tut01/updated_settings.jpg
  41. :alt: Updated Settings
  42. Updated Settings
  43. .. _logo:
  44. Adding your logo
  45. ----------------
  46. First, and most important, is the logo. Go to **Settings > CRX Settings**, where there are site-wide
  47. visual and design settings for your website. At the top, are two settings for your logo and
  48. favicon. Both will be scaled to fit wherever they are used, but we recommend
  49. the following image parameters:
  50. * **Logo:** probably does not need to be any larger than 500x500 pixels, unless you plan to have
  51. a giant logo. Any image ratio is fine, logos come in all shapes and sizes.
  52. .. figure:: images/tut01/Crx-Pharma.png
  53. :alt: logo.
  54. Right click and download this image to follow along.
  55. * **Favicon:** does not need to be any larger than 200x200 pixels. A 1:1 (square) image ratio is
  56. best here - if the image is not square, it will be scaled to a square.
  57. .. figure:: images/tut01/Crx-Pharma-favicon.png
  58. :alt: logo.
  59. Right click and download this image to follow along.
  60. .. note::
  61. We recommend PNG format at 300 DPI so that your logo will look sharp on high resolution
  62. mobile devices and retina displays. However, any image format will work.
  63. .. figure:: images/tut01/adding_logo.jpeg
  64. :alt: Adding the logo.
  65. Adding the logo.
  66. After uploading your logo and favicon, click "Save". You should now instantly see your logo
  67. applied in the dashboard. In a new browser tab, go to http://localhost:8000/ and you'll see that your
  68. logo and favicon show up on your site.
  69. .. figure:: images/tut01/logo_on_front.jpg
  70. :alt: The logo on our website.
  71. The logo on our website.
  72. .. _global-sass-colors:
  73. Global Site Colors with Sass
  74. ----------------------------
  75. For CRX-Pharma we will change the website's global colors with Sass. This a great way to get the exact colors you want for your site.
  76. In your file explorer, Navigate to **mysite>website>static>website>src>_variables.scss** . In this file, we can override the primary and secondary colors.
  77. *It's suggested you read through the comments on this page.*
  78. We are going to make the following changes:
  79. * "Uncomment out" line 22 and change `$blue` to `#1b477d`
  80. * "Uncomment out" line 23 and change `$gray-600` to `#1e8752`
  81. * "Uncomment out" line 36 and change `$white` to `#a4f1e9`
  82. The edited **_variables.scss** file show now look like this :
  83. .. figure:: images/tut01/changes_to_sass.jpg
  84. :alt: changes to the _variables.scss file.
  85. This screenshot was taken in Visual Studio Code. Your code editor may look different.
  86. * The final step is to compile the sass. In your terminal:
  87. * Stop your server with `ctrl + c`.
  88. * Run:
  89. .. code-block:: console
  90. $ python manage.py sass website/static/website/src/custom.scss website/static/website/css/custom.css
  91. * Restart server with `python manage.py runserver`
  92. This is what my terminal looked like following those steps:
  93. .. figure:: images/tut01/compile_sass_terminal.jpg
  94. :alt: compile steps in the terminal.
  95. This screenshot was taken on Windows using PowerShell. Yours may look different.
  96. Now hard refresh your browser at http://localhost:8000 and you should see the new background-color:
  97. .. figure:: images/tut01/body_bg_color.jpeg
  98. :alt: teal background
  99. The global colors have been updated!
  100. .. note::
  101. The background color in the search input is not ideal and will be addressed in the part 3 of the tutorial.
  102. The goal of the this section was to demonstrate how to use bootstrap variables to change global properties.
  103. You can now use bootstrap classes with "primary" or "secondary" and our new colors will override the defaults.
  104. Buttons are a great example of this. When adding a button or button link, they are options for style.
  105. The default style is "primary" which references the sass variable we set in the _variables.scss file. So with one line of code,
  106. anything that references primary will be dark blue (`#1b477d`).