<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Charles Watkins</title>
    <description>The latest articles on DEV Community by Charles Watkins (@charlesw_dev).</description>
    <link>https://dev.to/charlesw_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F666031%2F309470e0-f23f-4505-98d5-ab51bb0bba22.JPG</url>
      <title>DEV Community: Charles Watkins</title>
      <link>https://dev.to/charlesw_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/charlesw_dev"/>
    <language>en</language>
    <item>
      <title>How to build a beautiful docs site with VitePress and Render</title>
      <dc:creator>Charles Watkins</dc:creator>
      <pubDate>Thu, 26 Oct 2023 14:26:11 +0000</pubDate>
      <link>https://dev.to/charlesw_dev/ship-a-beautiful-docs-site-with-vitepress-and-render-3hc2</link>
      <guid>https://dev.to/charlesw_dev/ship-a-beautiful-docs-site-with-vitepress-and-render-3hc2</guid>
      <description>&lt;p&gt;Good documentation is one of the best ways to give your project instant credibility. Sure, you could stick it all in a README for a smaller project. That's fine. For larger projects, you'll want features like navigation, interactivity, search, and maybe even embedded videos. You'll also want something that looks good because presentation matters. &lt;/p&gt;

&lt;p&gt;Thankfully, there's an entire ecosystem of frameworks that make docs sites easy to build and services that make static sites easy to deploy. In this post, you'll learn how to build a docs site with &lt;a href="https://vitepress.dev/" rel="noopener noreferrer"&gt;VitePress&lt;/a&gt; and deploy it to the internet with &lt;a href="https://render.com" rel="noopener noreferrer"&gt;Render&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;VitePress is a highly customizable Vue-based static site generator for building docs sites. Think Docusaurus but with Vue instead of React. Render is a Platform-as-a-Service that makes deploying a web service or static site as easy as a few clicks (literally) via Git-based deployments with GitLab and GitHub. Think Heroku, but still free and easier to use. Using Vitepress and Render, you can build a fully functional (and surprisingly good-looking) docs site in moments. &lt;/p&gt;

&lt;p&gt;Before you get started, you’ll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A free &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; account&lt;/li&gt;
&lt;li&gt;A free &lt;a href="https://dashboard.render.com/register" rel="noopener noreferrer"&gt;Render&lt;/a&gt; account&lt;/li&gt;
&lt;li&gt;Some familiarity with Git and web development&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Scaffold your docs site with VitePress
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Create a directory for your VitePress project.
&lt;/h4&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-awesome-site 
&lt;span class="nb"&gt;cd &lt;/span&gt;my-awesome-site


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  2. Scaffold your VitePress project using their installation wizard.
&lt;/h4&gt;

&lt;p&gt;I recommend using the Default Theme because it looks great and is highly configurable. &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx vitepress init


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The scaffolded VitePress project will contain two types of files: a single configuration file and three &lt;a href="https://www.markdownguide.org/getting-started/" rel="noopener noreferrer"&gt;Markdown&lt;/a&gt; files: &lt;code&gt;index.md&lt;/code&gt;, &lt;code&gt;markdown-examples.md&lt;/code&gt;, and &lt;code&gt;api-examples.md&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;index.md&lt;/code&gt; file serves as your homepage, while the other two demonstrate using common VitePress features. You can customize the content of the Markdown files to begin writing your docs and add additional ones. &lt;/p&gt;

&lt;p&gt;You can use the configuration file to set a custom theme, update the title and description on the home page, and update the sidebar that appears on all doc pages. VitePress employs &lt;a href="https://vitepress.dev/guide/routing#file-based-routing" rel="noopener noreferrer"&gt;file-based routing&lt;/a&gt;, meaning the &lt;code&gt;index.md&lt;/code&gt; file serves as the main entry point at your-docs-domain and &lt;code&gt;markdown-examples.md&lt;/code&gt; is accessible at your-domain/markdown-examples.html.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Install the &lt;code&gt;vitepress&lt;/code&gt; package and run the app locally
&lt;/h4&gt;

&lt;p&gt;Add the &lt;code&gt;vitepress&lt;/code&gt; dependency to project and run it locally. VitePress will serve a development version of your docs site on &lt;code&gt;localhost:5173&lt;/code&gt; by default. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

yarn add -D vitepress
yarn docs:dev


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Navigate to &lt;a href="http://localhost:5173" rel="noopener noreferrer"&gt;http://localhost:5173&lt;/a&gt;. You should have a surprisingly beautiful docs site with three pages.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bj6ia45vahtvolnxgla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bj6ia45vahtvolnxgla.png" alt="Starter VitePress docs site running on localhost:5173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're having issues running &lt;code&gt;yarn docs:dev&lt;/code&gt; make sure that you've added VitePress using &lt;code&gt;yarn add -D vitepress&lt;/code&gt;. VitePress' installation wizard may not have installed VitePress as a package. &lt;/p&gt;

&lt;h3&gt;
  
  
  Push your project to GitHub
&lt;/h3&gt;

&lt;p&gt;Now that we’re happy with our site, let’s put it on GitHub. &lt;/p&gt;

&lt;h4&gt;
  
  
  1. Create a GitHub repo for your docs site
&lt;/h4&gt;

&lt;p&gt;Create a repo in GitHub–if you're new to using GitHub or need a quick refresher, check out their docs on &lt;a href="https://docs.github.com/en/get-started/quickstart/create-a-repo" rel="noopener noreferrer"&gt;creating a repo in GitHub&lt;/a&gt;. Check the box to add a &lt;code&gt;README.md&lt;/code&gt; and &lt;code&gt;.gitignore&lt;/code&gt; file with the Node template, as VitePress doesn't include them by default. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwcyy14lpvnw5wnrat7o3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwcyy14lpvnw5wnrat7o3.png" alt="Creating a GitHub repository with name of my-awesome-docs, description of My awesome docs. The Add README file box is checked. The add .gitignore has node selected."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Push your project to GitHub
&lt;/h4&gt;

&lt;p&gt;Now that you have a remote repository, it's time to push your code to GitHub. &lt;/p&gt;

&lt;p&gt;First, add &lt;code&gt;.vitepress/cache&lt;/code&gt; to your .gitignore file to ignore the cache created when you ran the project locally.&lt;/p&gt;

&lt;p&gt;Next initialize git, save a commit, and push it to GitHub. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

git init
git add .
git commit -m "first commit"
git remote add origin &amp;lt;YOUR REPOSITORY&amp;gt;
git push -u origin main


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Make sure to replace &lt;code&gt;&amp;lt;YOUR REPOSITORY&amp;gt;&lt;/code&gt; with your newly created GitHub repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy your docs site with Render
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Create a Static Site on Render
&lt;/h4&gt;

&lt;p&gt;Go to the Render dashboard and click &lt;strong&gt;Create a new Static Site&lt;/strong&gt; page. To the right, you’ll see an option to connect your GitHub (or GitLab) account. Click &lt;strong&gt;+ Connect account&lt;/strong&gt;  to grant Render access to the GitHub repo you made a few moments ago. You'll see your repository appear in a list with a &lt;strong&gt;Connect&lt;/strong&gt; button. Click &lt;strong&gt;Connect&lt;/strong&gt;. &lt;/p&gt;

&lt;h4&gt;
  
  
  2. Configure your deployment
&lt;/h4&gt;

&lt;p&gt;Once you’ve connected your repository, you’ll be asked to configure how it should be deployed. Give your docs site a name and specify your build command and publish directory. &lt;/p&gt;

&lt;p&gt;Set the build command to &lt;code&gt;yarn install; yarn docs:build&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Set the publish directory to &lt;code&gt;.vitepress/dist&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7erhrmr2juogkv5vwp54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7erhrmr2juogkv5vwp54.png" alt="Configuration screen for a new static site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default, Render sets the Node version to 14.17.0. VitePress requires Node version 18+. Click the &lt;strong&gt;Advanced&lt;/strong&gt; dropdown button and click the &lt;strong&gt;Add Environmental Variable&lt;/strong&gt; button. Set the key to NODE_VERSION and the value to 18.14.1–the latest LTS version of Node. &lt;/p&gt;

&lt;h4&gt;
  
  
  3. Deploy the docs site to Render
&lt;/h4&gt;

&lt;p&gt;Click the &lt;strong&gt;Create Static Site&lt;/strong&gt; button. Render will build and deploy your docs site to a custom onrender.com domain. Once the deployment process is finished, you can check out the live site. Here's mine: &lt;a href="https://vitepress-demo-vt0r.onrender.com" rel="noopener noreferrer"&gt;https://vitepress-demo-vt0r.onrender.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Going forward, Render will automatically build and deploy your docs site whenever you merge code into your main.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now what?
&lt;/h3&gt;

&lt;p&gt;In this tutorial, you learned how to build a docs site with VitePress and deploy it with Render, but there’s still more to do. You can &lt;a href="https://vitepress.dev/reference/default-theme-home-page" rel="noopener noreferrer"&gt;update the home page&lt;/a&gt;, add content by creating additional Markdown files, &lt;a href="https://vitepress.dev/guide/custom-theme" rel="noopener noreferrer"&gt;build or import&lt;/a&gt; custom themes, and put your project on a &lt;a href="https://render.com/docs/custom-domains" rel="noopener noreferrer"&gt;custom domain&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, go forth and document!&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional reading
&lt;/h3&gt;

&lt;h4&gt;
  
  
  VitePress
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://vitepress.dev/guide/getting-started" rel="noopener noreferrer"&gt;Getting Started&lt;/a&gt;&lt;br&gt;
&lt;a href="https://vitepress.dev/guide/using-vue" rel="noopener noreferrer"&gt;Using Vue in Markdown&lt;/a&gt;&lt;br&gt;
&lt;a href="https://vitepress.dev/guide/extending-default-theme" rel="noopener noreferrer"&gt;Extending the Default Theme&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Render
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://render.com/docs/static-sites" rel="noopener noreferrer"&gt;Static sites&lt;/a&gt;&lt;br&gt;
&lt;a href="https://render.com/docs/deploy-a-commit" rel="noopener noreferrer"&gt;Deploying a commit&lt;/a&gt;&lt;br&gt;
&lt;a href="https://render.com/docs/pull-request-previews" rel="noopener noreferrer"&gt;Build previews&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>documentation</category>
      <category>webdev</category>
      <category>writing</category>
    </item>
  </channel>
</rss>
