<?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>Forem: Ben Hacker</title>
    <description>The latest articles on Forem by Ben Hacker (@sigabiel).</description>
    <link>https://forem.com/sigabiel</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%2F1166956%2F132ee5c3-c30c-4723-9ab5-8792cb508bdc.png</url>
      <title>Forem: Ben Hacker</title>
      <link>https://forem.com/sigabiel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sigabiel"/>
    <language>en</language>
    <item>
      <title>Creating a serverless landing page using SvelteKit and Cloudflare</title>
      <dc:creator>Ben Hacker</dc:creator>
      <pubDate>Thu, 21 Sep 2023 14:37:28 +0000</pubDate>
      <link>https://forem.com/sigabiel/creating-a-serverless-landing-page-using-sveltekit-and-cloudflare-51d7</link>
      <guid>https://forem.com/sigabiel/creating-a-serverless-landing-page-using-sveltekit-and-cloudflare-51d7</guid>
      <description>&lt;p&gt;SvelteKit is a framework for building web applications with Svelte, a UI component framework that developers love for its performance and ease of use. Cloudflare is a web performance and security company that offers a variety of services, including serverless computing. In this article, we will show you how to use SvelteKit and Cloudflare to create and deploy a serverless landing page for your portfolio, blog, or business.&lt;/p&gt;

&lt;h2&gt;
  
  
  What You Need
&lt;/h2&gt;

&lt;p&gt;To follow this tutorial, you will need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A GitHub account&lt;/li&gt;
&lt;li&gt;A Cloudflare account&lt;/li&gt;
&lt;li&gt;A code editor of your choice&lt;/li&gt;
&lt;li&gt;Node.js and npm installed on your machine&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Clone the SvelteKit Portfolio Template
&lt;/h2&gt;

&lt;p&gt;We will use a SvelteKit portfolio template created by Ladvace as our starting point. This template has a simple and elegant design, with sections for your profile, skills, projects, and contact information. You can customize it to suit your needs and preferences.&lt;/p&gt;

&lt;p&gt;To clone the template, open your terminal and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Ladvace/SvelteKit-Portfolio.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a folder called SvelteKit-Portfolio in your current directory. Navigate to it and install the dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;SvelteKit-Portfolio
npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now run the development server and see the template in action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open your browser at &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Edit the Template Content
&lt;/h2&gt;

&lt;p&gt;Now that you have the template running locally, you can start editing the content to make it your own. The template uses Markdown files to store the data for each section. You can find them in the src/routes folder.&lt;/p&gt;

&lt;p&gt;For example, to edit your skills information, open the src/lib/skills.ts file and change the values to your needs. You can also add or remove fields as you wish.&lt;/p&gt;

&lt;p&gt;Similarly, you can edit the other sections by modifying the corresponding files in the src/ folder. For example, to add a new project to your portfolio, go to /src/lib/projects and fill it with the following template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    title: 'Your Project Title',
    technologies: ['Tech 1', 'Tech 2'],
    description: 'Your project description',
    url: 'https://yourproject.com'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To ensure a flawless deployment, we need to add the Cloudflare adapter to the svelte config.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; @sveltejs/adapter-cloudflare
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the import in your &lt;code&gt;svelte.config.js&lt;/code&gt; to &lt;code&gt;import adapter from '@sveltejs/adapter-cloudflare';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The config should look lie this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;adapter&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@sveltejs/adapter-cloudflare&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;vitePreprocess&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@sveltejs/kit/vite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('@sveltejs/kit').Config} */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;preprocess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;vitePreprocess&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;

    &lt;span class="na"&gt;kit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Deploy to Cloudflare Pages
&lt;/h2&gt;

&lt;p&gt;Now that you have customized your landing page, it's time to deploy it to Cloudflare Pages, a serverless platform that allows you to host websites directly from your GitHub repository.&lt;/p&gt;

&lt;p&gt;To do so, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log in to your Cloudflare account and go to the Pages dashboard.&lt;/li&gt;
&lt;li&gt;Click on the Create a project button and select your GitHub account.&lt;/li&gt;
&lt;li&gt;Choose the SvelteKit-Portfolio repository from the list and click on Begin setup.&lt;/li&gt;
&lt;li&gt;Click on Save and deploy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cloudflare will start building and deploying your landing page. This may take a few minutes. Once it's done, you will see a message saying "Your site is live" with a unique URL. You can also add a custom domain name if you want.&lt;/p&gt;

&lt;p&gt;That's it! You have successfully created and deployed a serverless landing page with SvelteKit and Cloudflare. You can now share it with the world and showcase your work.&lt;/p&gt;

&lt;p&gt;If you want to, you now have the option to add a custom domain so your-domain.com redirects to the Cloudflare page.&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>github</category>
      <category>landingpage</category>
      <category>cloudflare</category>
    </item>
  </channel>
</rss>
