# Configuration

## Automatic (for new projects)
If you are starting a fresh, new Wagtail site use the "quick start" procedure - a script will set up for you a new wagtail project with CjkCMS added to INSTALLED_APPS, and with basic page types configured and ready for editing content:

### Default theming (CDN-based Bootstrap 5.3 or MDBoostrap)

```
cjkcms start myproject
```
This will create a folder "myproject", and your django projet name will be "myproject". You should see the following output:
```
Creating a CjkCMS project called myproject
Success! myproject has been created

Next steps:
    1. cd myproject/
    2. python manage.py migrate
    3. python manage.py createsuperuser
    4. python manage.py runserver
    5. Go to http://localhost:8000/backend/ and start editing!
```

### Webpack-based theming (Bootstrap 5.3 or MDBoostrap)
If you intend to use Webpack-based Bootstrap to modify the default theme, use the advanced "webpack" project template, as described [here](../configuration/webpack.md).


## Manual (for both new and existing Wagtail sites)

If you want to add CjkCMS to an existing Wagtail site, or if you prefer to manually configure CjkCMS in a new or existing Wagtail site, follow these steps:

> Note: all steps below (including changes to the homepage) are required only for manual setup. 
> They are automatically applied when using the "quick start" / automatic configuration procedure.

* Add CjkCMS and its requirements to ```INSTALLED_APPS``` in your project configuration (e.g. ```base.py```):
```python
INSTALLED_APPS = [
    ...
    ### wagtail-cjkcms ###
    "cjkcms",
    "wagtailseo",
    "wagtailcache",
    "wagtail.contrib.table_block",
    "wagtail.contrib.settings",
    "django_bootstrap5",
    "wagtail.contrib.sitemaps",
    "django.contrib.sitemaps",
    "wagtail_color_panel",
    ### end wagtail-cjkcms ###
```
* Run migrations:
```
python manage.py migrate
```
* Add ```cjkcms.urls``` to ```urls.py``` in your project:
```python
from cjkcms import urls as cjkcms_urls

urlpatterns = [
    ...
    # add cjkcms urls
    path("", include(cjkcms_urls)),

    # comment out the default wagtail search view,
    # it will be replaced by the cjkcms search view
    # path("search/", search_views.search, name="search"),
    ...
]
```

## Optional (but strongly suggested) setup steps

Out of the box, CjkCMS can provide your project with generic, reusable pages:
`ArticleIndex`, `Article`, `WebPage` which you can use in your project, or extend with additional functionality. CjkCMS pages provide you with a generic "body" section and, using ```wagtail-seo``` package, a basic SEO functionality. However, they are not easy to extend with new block types and new functionality, tailored to your project.

## Changing the homepage: 
By default, Wagtail adds a homepage inherited from Page. If you want to use CjkCMS WebPage as your homepage (suggested - will be automatically setup if you use the quick start guide), you need to change the homepage to `WebPage`. Otherwise you can start adding new CjkCMS pages to your project anywhere in the page tree, which may be useful if you are adding the CMS to an existing website.

### Change to WebPage model:

If you are starting a new website, we suggest to use CjkCMS WebPage (or a page inherited from it) as your home page, for the additional functionality provided by CjkCMS. 

To do this, you need to:

- log in to the wagtail admin
- go to Pages
- add a new page (any CjkCMS page type, e.g. most generic WebPage) at the top level, next to the Homepage
- go to Settings -> Sites and change the root page of your site to the new CMS page
- go back to pages, if there is no custom content in the default (old) homepage, you can delete it.

### Old Homepage cleanup

You cannot yet remove the HomePage model from home/models.py - first you need to delete that page in the admin panel - see section above. A safer solution is to keep the HomePage model, bug deactivate it by adding `max_count = 0` to the Homepage model, which effectively hides it from admin interface.

In `/home/models.py` change this:

```
class HomePage(Page):
    pass
```

to that:

```
class HomePage(Page):
    max_count = 0
```