Getting Started with Spectre
Thanks for going with Spectre as your theme of choice! Let’s get you set up. You can create a new Astro project with this theme by running:
First, a small introduction to the project structure:
There are other files and directories in the repository as well, but we’re going to ignore them in this guide since they’re not relevant.
Configuring the Theme
First, head to the src/assets/
directory. You’ll find a pfp.png file there. Replace it with your own profile picture!
Next, open the astro.config.mjs
file and change the site
parameter so that it matches your own site:
After that, you can configure the site title and other details for the pages in the integration options:
Optionally, you can also add the themeColor
and twitterHandle
parameters next to the name
parameter in the integration options.
The theme color defaults to #8c5cf5
. The Twitter handle doesn’t have a default value, and the relevant meta tags will be omitted if it’s not provided.
Comments
This theme has comments powered by giscus. If you want to use them, first configure your repository on their website. Then, add the giscus
option and configure it based on the script tag you get from giscus:
If you want to modify the giscus colors, you can do so in the styles/giscus.css
file. If you do so, make sure to provide the theme as https://your-site.tld/styles/giscus
.
Alternatively, you can change the giscus.theme
option to one of the provided options by giscus.
Authoring Content
Now, let’s move on to the src/content/
directory. You’ll find a few JSON files there, along with a few directories. The difference? The JSON files are used for quick infos, social links and other information that doesn’t need the full MDX capabilities. The directories are for the actual content, like blog posts and projects.
You’ll notice there’s a other/
directory too, which only contains one file: about.mdx
. This is where you can put your about page content that still needs the full MDX capabilities, but doesn’t fit into the other categories.
Let’s go down the list of JSON files and see what you can put in them:
Info
The info.json
file contains the quick info you can see below your profile picture and name on the main page. It will appear in the same order you put it into this file! An item in the info.json
file looks like this:
Spectre supports both Lucide and Simple Icons.
Socials
The socials.json
file is similar to the info.json
file in terms of structure and is used for the social links in the second card on the home page.
Tags
The tags.json
file holds all tags for your blog posts. Whenever you want to create a new tag, add it here!
Work
Last but not least in terms of JSON files, work.json
. This is where you put all your work experience! The following example contains all parts in the correct order, meaning that duration
will come first when actually displayed on the page:
Posts
Let’s move on to the real content. The posts/
directory is home to all your blog posts, written in MDX. To create a new post, simply create a new file! The filename will be used as the slug for the page.
Each post can provide the following information in the frontmatter:
After the frontmatter, you can write your post in MDX! If you’re not familiar with MDX, you can find a guide here.
As for the images, it is recommended to place them in
src/content/assets
. That way, you can separate them from normal images.
Projects
The projects/
directory is similar to the posts/
directory, but for projects. There’s a few differences in the frontmatter:
Other
The src/content/other/
directory is home to all MDX content which does not need it’s own category. For example, you’ll find an about.mdx
file in here, which is responsible for the “About me” section on the homepage!
Deploying
Spectre uses the node
adapter by default. If you want to deploy to Netlify or Vercel, you need their respective adapters:
When deploying to GitHub Pages, make sure to remove the adapter from the astro.config.ts
file altogether:
After doing so, you can follow the official guide to deploy your site.
When not using an adapter, make sure to set export const prerender
to true
in src/pages/styles/giscus.ts
or to remove the file altogether if you don’t provide a custom giscus theme yourself.
Additionally, you need to update the postbuild
script in your package.json
:
Modifying the theme
As with all themes, you might wish to modify it. In terms of content, you should know where you can do that! If you want to modify the primary color for example, you can do so in the src/styles/globals.css
file:
Variable | Description | Default |
---|---|---|
--primary | The primary color of the page. | #8c5cf5 |
--primary-rgb | RGB version of the primary color. | 140, 92, 245 |
--primary-light | Used for links. | #a277ff |
--primary-lightest | Used for links. | #c2a8fd |
← Back to blog