Insites Docs Developers guide Get StartedSetting Up Your Project

Setting Up Your Project

Last updated on June 26, 2024.

Insites operates on the principle that working offline should seldom be necessary. You can create and modify files using a code editor in your local file system while remaining continuously connected to your Instance. This connection allows the Insites engine to analyze and interpret your codebase so that you can deploy changes to your code as needed or have the system make the updates every time changes to a file are made. In essence, you write code locally but execute it remotely.

Insites directory structure

Your code needs to be organized in a specific way for it to be correctly interpreted by Insites. The simplest method for initializing code with the proper folder structure is to use the command.

Start by creating an empty folder for your project named in this example, then navigate to it from the command line:

Overview of the directory structure

The command creates all of the required folders used by Insites. You need to know the basic directories used to store files and web pages. In addition, you must also know the directories used to handle data.

Note

Please refer to our Codebase documentation for a comprehensive discussion on the Insites directory structure.

Assets

Every static, publicly available asset is stored in the folder. Images, JavaScript, fonts, CSS files, or any downloadable documents go here. You can organize the files any way you want, but consider using the following structure to separate various asset types:

  • for images
  • for JavaScript files
  • for the page CSS
  • for the font files
Note

Please take note of the following pointers regarding assets:


  • You may refer to our documentation on Assets for more details on managing and using assets on your Instance.

Content

Put every content page in . You may refer to the Views: pages, layouts, and partials section for more details.

Data

Put the schema (the structure of your database written in YAML) in .

GraphQL queries and mutations are used to save, retrieve, or modify data from the database. In addition, GraphQL is also used to add or create items in a database. All these queries and mutations go to .

Now that you are inside the folder create the directory structure by executing the following command:

After executing the command, a success message is displayed, confirming that the directory structure was created. There are now a variety of new files and folders in your project's root directory. The subsequent sections in this document explain what they are for. Also, note that the command created an example HTML page with a welcome message.

Note

The Getting Started with the Insites CLI Tool documentation presents a deep dive into the topics discussed in the following sections:


Creating an Environment for an Instance

This step establishes a connection between your local codebase and an Instance. This connection allows you to deploy changes from your local codebase onto the Instance.

Use the following command to simultaneously create an environment and add an Instance to it:

Important

Please take note of the following important pointers:


  • Run all commands discussed in this tutorial in the project root directory.
  • Apart from alphanumeric characters, only underscores and dashes can be used in the environment-name. Other special characters could cause an error.
  • You can view your Instance's UUID using the Console or the Insites Modules page within the Instance Admin Settings.

Deploying to an Instance

Once you have connected your codebase to an Instance, you can now deploy changes from your codebase in your local machine to your Instance.

The deployment process is initiated by using the following command in the root of your project folder:

After deployment, you can see your project on your Instance.

Syncing a local codebase with an Instance

Syncing is a feature that enables you to set up your codebase and Instance so that any changes you make to your codebase are immediately pushed and reflected on your Instance. To enable syncing, run the following command from the root directory of your project:

Important

We suggest you only use on staging Instances. Using this command on a production Instance causes changes to your codebase to be immediately deployed to a live (production) site and can be dangerous. Proceed with caution if using in a production environment.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.