<?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: André Buse</title>
    <description>The latest articles on DEV Community by André Buse (@andrebuse).</description>
    <link>https://dev.to/andrebuse</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%2F1197595%2F3185b73f-bf5d-4bb6-834a-5625a5793c21.png</url>
      <title>DEV Community: André Buse</title>
      <link>https://dev.to/andrebuse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrebuse"/>
    <language>en</language>
    <item>
      <title>Concept: Including dev.to Posts in a Static Hugo Site</title>
      <dc:creator>André Buse</dc:creator>
      <pubDate>Mon, 30 Oct 2023 19:25:27 +0000</pubDate>
      <link>https://dev.to/andrebuse/concept-including-devto-posts-in-a-static-hugo-site-5dfh</link>
      <guid>https://dev.to/andrebuse/concept-including-devto-posts-in-a-static-hugo-site-5dfh</guid>
      <description>&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; &lt;em&gt;I found a way more elegant solution. I will leave this post up for reference, but I won't actually implement this. Instead, I'll do it the other way round. I found out that &lt;code&gt;dev.to&lt;/code&gt; can automatically import posts from RSS feeds, and Hugo can generate RSS feeds. So that feels way more natural and involves less code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I am currently building a small personal website with &lt;a href="https://gohugo.io/"&gt;Hugo&lt;/a&gt; and want to include a blog on it. However, just a static blog on my site won't allow people to comment or otherwise interact with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Idea and Motivation 💡
&lt;/h2&gt;

&lt;p&gt;There are some awesome (self-hosted) open source blog systems that do allow interactions, but I don't want to go this route. I want to be able to connect with other developers easily, and also have better discoverability than just a website. This is where &lt;code&gt;dev.to&lt;/code&gt; comes into play: It has an awesome community of developers! 🎉&lt;/p&gt;

&lt;p&gt;So the plan is: Use my personal site to embed posts from &lt;code&gt;dev.to&lt;/code&gt; (with linking back between them). This will achieve a few things that I find important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I can use &lt;code&gt;dev.to&lt;/code&gt; to connect with other developers&lt;/li&gt;
&lt;li&gt;visitors of my website can easily see my content without having to leave the site&lt;/li&gt;
&lt;li&gt;people that want to further engage can follow the link to the &lt;code&gt;dev.to&lt;/code&gt; post&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I personally don't mind that this will duplicate content. I think it's a good idea to have a mirror anyway. But I can see why some people wouldn't want that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Planned Implementation 📝
&lt;/h2&gt;

&lt;p&gt;I already have an idea on how to implement this. My personal website is made using Hugo, so the solution should neatly integrate into this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forem API
&lt;/h3&gt;

&lt;p&gt;As you might know, &lt;code&gt;dev.to&lt;/code&gt; is a &lt;a href="https://www.forem.com/"&gt;Forem&lt;/a&gt; instance. Forem exposes a JSON API that can be used to query posts. For me the important endpoint is &lt;code&gt;GET /api/articles&lt;/code&gt; which will give you published posts, optionally filtered by a given &lt;code&gt;username&lt;/code&gt; parameter. Perfect!&lt;/p&gt;

&lt;h3&gt;
  
  
  Hugo Integration
&lt;/h3&gt;

&lt;p&gt;How will I get this data into my static site? I sure could add some JavaScript to load the posts dynamically, but to be honest I prefer them to be static too. So instead, I will use Hugo to fetch the content automatically for me.&lt;/p&gt;

&lt;p&gt;Hugo has a &lt;a href="https://gohugo.io/functions/data/getjson/"&gt;&lt;code&gt;getJSON&lt;/code&gt;&lt;/a&gt; function which can fetch external data. When the static site is built, those resources are fetched so that the result can be used in the website templates.&lt;/p&gt;

&lt;p&gt;This should be enough for my usecase. For more advanced scenarios I would use a &lt;a href="https://gohugo.io/hugo-modules/"&gt;Hugo Module&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Action
&lt;/h3&gt;

&lt;p&gt;With the posts included in my static site, the only thing missing is some way to easily rebuild and deploy the static site whenever I create a new &lt;code&gt;dev.to&lt;/code&gt; post. Therefore I will create a GitHub Action that does exactly this.&lt;/p&gt;

&lt;p&gt;I won't automate this in the beginning since I want to keep track if everything works as expected. This will change once I'm sure that my code is running stable. GitHub has an API endpoint that allows triggering a Workflow, so I can use a &lt;code&gt;dev.to&lt;/code&gt; webhook which triggers the CI for every new post. 🪄&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks for reading! ❤️
&lt;/h2&gt;

&lt;p&gt;I hope you found this concept/idea interesting. The implementation will follow, however I needed a first post here on &lt;code&gt;dev.to&lt;/code&gt; to test the API. So I thought, why not share the idea? That way I have a post to test my code with, plus other people can see what I'm working on!&lt;/p&gt;

&lt;p&gt;I will probably post a new article once this project is working, including anything I learned along the way. ✨&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>hugo</category>
      <category>api</category>
    </item>
  </channel>
</rss>
