Getting Started
Get started with the Astro Theme Pure
Installation#
Two way to install. “Template” way is lightweight and simple, but hard to update; while “Fork” way is easy to update but needs some skills for git.
Install Using Template#
Step 1: Install the theme#
Execute the following command in the your user directory to install the theme:
bun create astro@latest --template cworld1/astro-theme-pureshellpnpm create astro@latest --template cworld1/astro-theme-pureshellyarn create astro --template cworld1/astro-theme-pureshellnpm create astro@latest -- --template cworld1/astro-theme-pureshellBy default, this command will use the template repository’s main branch. To use a different branch name, pass it as part of the --template argument: cworld1/astro-theme-pure#<branch>.
Step 2: Follow the CLI wizard#
Answer the questions and follow the instructions of the CLI wizard.
Step 3: VOILA!#
You can now start the Astro dev server ↗ and see a live preview of your project while you make it your own!### Install Using Fork
You only need to click fork button at theme repository ↗ to create your project; then clone the forked repository to your local machine.
git clone https://github.com/<your-username>/astro-theme-pure.gitshellThen, you can start the Astro dev server and see a live preview of your project while you make it your own!
Start the Dev Server#
Go to your project directory:
cd ./<your-project>shellshell bun dev shell pnpm dev shell yarn run dev shell npm run dev Next, please read the configuration notes first and continue configuring the theme.
Migrate to Astro#
See Astro: Migrate an existing project to Astro ↗.
Theme File Structure#
The theme file structure is as follows:
public: Static resources that will be copied to the root directorysrc:assets: Static resourcescomponents: Components used in the theme, also include user-like components, likeCard,Collapse,Spoiler, etc.layouts: Basic site layoutspages: Pages like404,about,blog,docs,index, etc.plugins: Extended plugins used in the themetypes: Typescript type definitionsutils: Utilitiessite.config.ts: Theme configuration file
astro.config.mjs: Astro configuration fileeslint.config.mjs: ESLint configuration fileprettier.config.mjs: Prettier configuration fileuno.config.ts: UnoCSS configuration filetsconfig.json: Typescript configuration filepackage.json: Package information
Simple Setup#
-
Remove docs files
- Remove the
src/pages/docsdirectory - Remove the menu declaration in
src/site.config.ts:
src/site.config.ts
tsexport const theme: ThemeUserConfig = { // ... /** Configure the header of your site. */ header: { menu: [ { title: 'Blog', link: '/blog' }, { title: 'Docs', link: '/docs' } // ... ] } }- Remove the Content Collection for docs in
src/content.config.ts:
src/content.config.ts
tsconst docs = defineCollection({ loader: glob({ base: './src/content/docs', pattern: '**/*.{md,mdx}' }), schema: ({ image }) => z.object({ ... }) }) export const collections = { blog, docs } export const collections = { blog } - Remove the
-
Remove
packagesdirectory (this will be imported by our NPM package) -
Change the site favicon.
Replace the
public/favicon/*files with your own favicon. -
Replace your avatar image.
Replace the
src/assets/avatar.pngfile with your own avatar image. -
Configure the site
You can configure your project inside the
src/site.config.tsconfiguration file:src/site.config.ts
tsexport const theme: ThemeUserConfig = { author: 'CWorld', title: 'Astro Theme Pure', site: 'https://astro-pure.js.org', description: 'Stay hungry, stay foolish' // ... } export const integ: IntegrationUserConfig = { /* ... */ } // ... -
Typescript Syntax
The configuration file
site.config.tsuses Typescript syntax. If you are not familiar with TS syntax, please read about it here ↗ first.