Create New Page

How to Create a New Page

Here is the example on how to create your custom page and add it to the leftsidebar menu, breadcrumbs and also meta tag.

1. Create a new folder in src/pages . ex. NewPage, and then create a js file in src/pages/NewPage with name index.ts

Example :-
  • As you know, there are 2 different types of layouts, first is Blank Layout and second is Full layout.
  • - if you want to make your page blank layout, then you need to wrap your page's content with <Container fluid={false}>

    - if you want to make your page with full layout, then you need to wrap your page's content with

    tag and <Container fluid={true}>

  • Add Breadcrumbs component. it's a common component, it's used to add breadcrumbs in your page.

    - You have to pass 2 props here, first is title and second is breadcrumbItem.

    - the title prop refers to page title and the breadcrumbItem refers to page's breadcrumb item's title.

  • Add MetaTags to give a html title to your page.

- Full Layout Components

import React from 'react';
import { Container } from "reactstrap";

//Import Breadcrumb
import BreadcrumbItem from "../../Components/common/Breadcrumb";
       
    const newPage = () => {
        return (
        <div>
            <div className="page-content">
                <Container fluid={true}>
                    <BreadcrumbItem title=="New Page"
                    breadcrumbItem="New Page" />

                            //write Html code or structure

                </Container>
            </div>
        </div>
    );
} 
export default newPage;

- Blank Layout Components

import React from 'react';
import { Container } from "reactstrap";
                                                        
const newPage = () => {
    return (
        <div>
            <Container>
                //write Html code or structure
            </Container>
        </div>
    )
}
                                                        
export default newPage;

2. Add your new page's route in src/Routes/allRoutes.js file.

  • Check the Routes section to see how to add routes to the web application.
  • if you want to create a page with blank layout, then add your page's routes in publicRoutes
  • Example :-

        import newPage from "../pages/newPage"
    
        const publicRoutes = [
        { path: "/new-page", component: <newPage /> }
        ]
    
  • if you want to create a page with full layout, then add your page's routes in authProtectedRoutes
  • Example :-

        import newPage from "../pages/newPage"
    
        const authProtectedRoutes = [
        { path: "/new-page", component: <newPage /> }
        ]