Skip to content

VitePress is a popular static site generation library, especially for technical documentation.  With Pintheon, it's easy to deploy you VitePress docs to the internet.


Video Walkthrough


Prerequisites


Process

First step is to create you VitePress site, this tutorial isn't about how to use VitePress, to follow the docs for to understand fully how to use the library.

In this case we will be scaffolding a very basic site.


Scaffold the Site

Open a terminal in the directory in which you want your project files to exist, then run:

npx vitepress init

VitePress will give you a set of interactive prompts that act as a basis for the site setup.

┌  Welcome to VitePress!

◇  Where should VitePress initialize the config?
│  ./docs

◇  Where should VitePress look for your markdown files?
│  ./docs

◇  Site title:
│  My Awesome Project

◇  Site description:
│  A VitePress Site

◇  Theme:
│  Default Theme

◇  Use TypeScript for config and theme files?
│  Yes

◇  Add VitePress npm scripts to package.json?
│  Yes

◇  Add a prefix for VitePress npm scripts?
│  Yes

◇  Prefix for VitePress npm scripts:
│  docs

└  Done! Now run pnpm run docs:dev and start writing.

Site Files
8c3a4cfee3b7d5e20b440147bc6efeb5.png
config.mts

This file configures the site. This file needs to be updated so that it works when uploaded to your Pintheon node.
We will update it, adding an environment variable, so routing is consistent for development, and when built for deplyment on Pintheon. We add these lines to the config:

// Base URL configuration - will be available as import.meta.env.BASE_URL
base: process.env.NODE_ENV === 'production' ? '/home/' : '/',
// Ensure Vite knows about our base URL
vite: {
  define: {
    'import.meta.env.BASE_URL': JSON.stringify(process.env.NODE_ENV === 'production' ? '/home/' : '/')
  }
}

So the config now looks like this:

import { defineConfig } from 'vitepress'

  // https://vitepress.dev/reference/site-config
  export default defineConfig({
  // Base URL configuration - will be available as import.meta.env.BASE_URL
  base: process.env.NODE_ENV === 'production' ? '/home/' : '/',
  // Ensure Vite knows about our base URL
  vite: {
    define: {
      'import.meta.env.BASE_URL': JSON.stringify(process.env.NODE_ENV === 'production' ? '/home/' : '/')
    }
  },
  title: "Pintheon Demo",
  description: "A Pintheon Demo",
  themeConfig: {
    // https://vitepress.dev/reference/default-theme-config
    nav: [
      { text: 'Home', link: '/' },
      { text: 'Examples', link: '/markdown-examples' }
    ],

    sidebar: [
      {
        text: 'Examples',
        items: [
          { text: 'Markdown Examples', link: '/markdown-examples' },
          { text: 'Runtime API Examples', link: '/api-examples' }
        ]
      }
    ],

    socialLinks: [
      { icon: 'github', link: 'https://github.com/vuejs/vitepress' }
    ]
  }
})

package.json
51bb4e99c4fa254ff2793d6b1347c0ea.png

This file defines the dependencies, as well as settings for building the project. We want to update it to include the 'NODE_ENV' environment variable we defined above:

{
  "scripts": {
    "docs:dev": "vitepress dev",
    "docs:build": "NODE_ENV=production vitepress build",
    "docs:preview": "vitepress preview"
  },
  "dependencies": {
    "dotenv": "^17.2.3"
  },
  "devDependencies": {
    "@types/node": "^24.6.2"
  }
}

This is specifically so the routing works in the built app. To build and run for development we call:

npm run docs:dev

The site will be built and runs on: http://localhost:5173/


markdown files
76ad01c4bf01c77c682d00421081c58c.png

The markdown files are used for the site content, customize these, add more etc., in order to customize the site content.


Deploying to Pintheon

First build the site with:

npm run docs:build

 

9c204ace7c0d8dc5d71d30f3f3a152c5.png

All the built assets are built into the /dist directory


 

ec78acf4d0a89f812552ad47959b7851.png

We want to compress these into a zip file so we can upload them to the Pintheon node.


Uploading zip to Pintheond5c5d12a00314f026c22279def7fbc13.png

Log into your Pintheon node, and navigate to Settings. Under 'Homepage', choose 'Upload' from the drop-down.

 


791f9b13c725c990efb3c1e03fa36291.png

Then press the upload button and find the zipped site assets.


e7bb366ea14fe5ee037bcd7f8a4dfa38.png

If upload was successful, a confirmation will show.


 

c314fcf26c1e79af3a2123b2a7d03b35.png

The site is now served on: https://127.0.0.1:9998/home/


 

3519a9a378d86085e7fe0f6f39b2fed7.png

Log into your pinggy acccount, and copy your token.


1a24e5fde23fe7baf12eafea7c7f28fe.png35d13d2f8e8e33f63645fc3d7465aadf.png

Set your Pinggy token in Metavinci.


 

65df0a6a59cfdeffdebc332e76839280.png

By default metavinci assumes tunnels will use pinggy pro, if you want to use pinggy free, you must set it in metavinci.


Serving your site to the Internet
2d184283b6ca2997743348d40b8f6da8.png

Open a tunnel with metavinci


 

2d58e9ae0b3325b000d1f1199ea9538a.png

The Pinggy terminal will popup, and showing the links to where you site is being served on the internet.

That's it!  You now have a custom website served to the web, directly from your computer.