DEV Community

Arman @programmerByDay
Arman @programmerByDay

Posted on • Originally published at jekyllpad.com

How to Host an External Blog on Your Site's /blog URL

Having a blog as part of your website is like opening a window into the heart of your business or passion project. It’s not just about sharing ideas; it’s a powerful tool to connect and grow. Especially when it’s located right on your site, under the easy-to-remember /blog URL. This isn't just good for your audience; it's great for search engines too.

Modern and engaging blog page on a desktop in a cozy home office setup, illustrating the integration of personal passion with professional web presence

Search engines love fresh content. A blog that's part of your site means there's always something new for them to index. This can boost your site's visibility and lead more people to discover what you have to offer. Whether you’re sharing insights, tips, or stories, each post helps paint a picture of what makes your work unique.

Now, imagine having an external blog on your website. This could be a blog you've started on WordPress, Medium, or even GitHub Pages. \
Integrating this into your site could bring all sorts of benefits. It means you can tap into the features and ease of use these platforms offer while keeping your audience close to home.

Your readers won't have to hop between sites to catch up on your latest posts. Everything’s right there, under your /blog URL, making for a smoother, more cohesive user experience. On top of that, You'll get SEO juice for your website on every content you publish.

Understanding the Challenge

Many website owners want their blog to live under the easy-to-remember /blog URL but find the process challenging. Why is that?

Web developer puzzled over blog integration, comparing subdomain and directory for SEO and user experience

Well, every piece of your website needs to fit perfectly to create a smooth, enjoyable experience for your visitors. When it comes to adding a blog, especially one that's hosted externally on platforms like WordPress, Medium, or even GitHub Pages, the fit needs to be just right.

The biggest hurdle? Ensuring a cohesive user experience and seamless integration. Your blog isn't just a collection of posts; it's a vital part of your website's identity. When visitors click from your homepage to your blog, they shouldn't feel like they've left your site. The design, navigation, and overall feel should be consistent. This unity is crucial not just for user experience but from an SEO standpoint as well.

Speaking of SEO, let's talk about why hosting your blog as a subdomain (like blog.yoursite.com) might not be the best idea. While it might seem like a simple solution, search engines like Google treat subdomains almost like separate websites. This means that all the hard work you put into your blog posts—those keywords you've researched, the quality content you've created—doesn't directly contribute to the SEO authority of your main website domain. Instead, hosting your blog in a subdirectory (like yoursite.com/blog) ensures that your main site benefits from every visitor, every link, and every bit of recognition your blog receives.

Achieving this seamless blend of blog and website, where each blog post reinforces the strength of your main domain, is the key to overcoming the integration challenge. It's about making sure every piece of the puzzle fits perfectly, enhancing both the user experience and your site's SEO performance.

Solutions Overview

When you decide to host an external blog on your website's /blog URL, you're taking a significant step towards enriching your site's content and SEO. But how do you go about it? There are two main paths you can take, each suited to different kinds of website management scenarios. Let's break them down.

Crossroad signpost illustrating the choice between hosting server control and source code control for blog integration

  1. If You Have Control of the Web Server \
    If you're in charge of your website's hosting web server—think Apache, Nginx, or similar platforms—you have the freedom to configure the server settings directly. This path allows you to set up reverse proxies, redirects, and other server-level configurations to seamlessly integrate your external blog into your main site. It's a bit like having the master keys to the building; you can set up the space exactly how you like it.

  2. If You Have Control of the Source Code of Your Website \
    For those who have direct control over their website's source code but might not have access to server settings, there's another route. This approach involves integrating the blog into your site through coding solutions—embedding, API calls, or even custom scripts that pull in your blog content to the /blog section of your site. It's akin to crafting the interior of your space to make it welcoming and functional, even if you can't alter the building itself.

Each of these paths has its set of tools and techniques, which I'll dive into in the next sections. Whether you're a server guru or a code wizard, there's a way to make your blog feel right at home on your website.

Integrating Blog using Web Server

Incorporating an external blog into your website's /blog URL can be seamlessly achieved through the strategic use of web server configurations, specifically with servers like NGINX and Apache. These powerful tools have the capability to act as intermediaries, or proxies, funneling requests from your visitors directly to an external blog platform without the user ever noticing a difference.

Web developer configuring reverse proxy on NGINX, Apache, and IIS for blog integration

Imagine you're at a busy train station, but instead of trains, you're directing internet traffic. This is what a reverse proxy does. It's like a traffic director for the web. When someone visits your blog, the reverse proxy decides where to send that request on your network. This way, you can have your blog somewhere else but make it appear as if it's part of your main website, under the /blog URL.

What is a Reverse Proxy and How It Works?

A reverse proxy sits between the internet and your web server. Think of it as a middleman. When someone types in your website looking for your blog, the reverse proxy takes this request and forwards it to where your blog is actually hosted, like on WordPress, Medium, or GitHub Pages. Then, it takes the blog's response and sends it back to the visitor. All of this happens behind the scenes, making your blog feel like an integral part of your website without actually being on your main server.

NGINX Reverse Proxy

NGINX is a popular choice for setting up a reverse proxy due to its efficiency and flexibility. To host an external blog under the /blog URL with NGINX, you would use a configuration snippet like this:

location /blog/ {
    proxy_pass https://your_external_blog_address;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
Enter fullscreen mode Exit fullscreen mode

This tells NGINX that whenever someone visits yourwebsite.com/blog, it should forward those requests to https://your_external_blog_address and then serve that content back to the visitor as if it were coming from your own site.

Apache Reverse Proxy

Apache, another widely used web server, can also be configured to serve an external blog under the /blog URL. An Apache reverse proxy configuration might look like this:

ProxyPass "/blog" "https://your_external_blog_address"
ProxyPassReverse "/blog" "https://your_external_blog_address"
Enter fullscreen mode Exit fullscreen mode

This setup directs any traffic going to yourwebsite.com/blog to your external blog platform and then back to the user, making the blog appear to be hosted on your main site.

Reverse Proxy in IIS

For those using Windows servers, Internet Information Services (IIS) can also be configured to use a reverse proxy. With the URL Rewrite module and Application Request Routing, you can set up a rule like:

<rule name="ReverseProxyInboundRule1" stopProcessing="true">
    <match url="blog/(.*)" />
    <action type="Rewrite" url="https://your_external_blog_address/{R:1}" />
</rule>
Enter fullscreen mode Exit fullscreen mode

This IIS configuration forwards all requests from yourwebsite.com/blog to the external blog, ensuring visitors access your blog content under your main website’s URL.

Integrating Blog using Source Code

Integrating an external blog into your website's /blog URL through source code manipulation involves setting up a proxy within your application. This method allows you to route requests for your blog through your main application, fetching and displaying content from the external blog platform as if it were part of your original site. Let's explore how this can be achieved in various server-side and client-side frameworks.

Next.js

To integrate an external blog into your Next.js application under the /blog URL using Next.js rewrites, you can leverage the rewrites feature in your next.config.js file. This approach does not require server-side API routes but rather a configuration that tells Next.js to proxy requests for /blog to your external blog platform. Here’s how you can do it:

Open or create the next.config.js file in the root of your Next.js project.

  1. Add a rewrites async function to define custom rewrite rules.
  2. Here is an example configuration that redirects requests from /blog to https://external-blog.com:
module.exports = {
  async rewrites() {
    return [
      {
        source: '/blog/:slug*',
        destination: 'https://external-blog.com/:slug*' // Proxy to External Blog
      }
    ]
  },
}
Enter fullscreen mode Exit fullscreen mode

This setup ensures that any request to yoursite.com/blog/_ will be proxied to the corresponding path at https://external-blog.com/_, seamlessly integrating the external blog content under your site’s /blog path without changing the URL in the browser.

Remember, while rewrites are powerful for seamlessly integrating content, they do not enable server-side rendering of the proxied content. The content will be fetched client-side, which means the initial HTML response will not contain the blog content. This approach is great for user experience but consider SEO implications, as search engines may not index the proxied content as part of your site.

Next.js Server-Side

Next.js supports API routes, which you can use to create a proxy endpoint for your external blog.

  1. Create a new API route in your Next.js project under pages/api/blog/[...slug].js.
  2. Use fetch to call the external blog API and return the blog content.
// pages/api/blog/[...slug].js
export default async (req, res) => {
  const response = await fetch(`https://external-blog.com/${req.query.slug.join('/')}`);
  const data = await response.text();

  res.setHeader('Content-Type', 'text/html');
  res.send(data);
};
Enter fullscreen mode Exit fullscreen mode

C# ASP.NET Core

ASP.NET Core can use middleware to forward requests to an external blog.

Create a middleware that intercepts requests to /blog and forwards them.

// In your Startup.cs
app.Use(async (context, next) =>
{
    if (context.Request.Path.StartsWithSegments("/blog", out var remainder))
    {
        var client = new HttpClient();
        var externalResponse = await client.GetAsync($"https://external-blog.com{remainder}");
        var content = await externalResponse.Content.ReadAsStringAsync();
        context.Response.ContentType = externalResponse.Content.Headers.ContentType.ToString();
        await context.Response.WriteAsync(content);
    }
    else
    {
        await next();
    }
});
Enter fullscreen mode Exit fullscreen mode

Client-side Frameworks (React, Vue.js, Angular, and Svelte)

For client-side frameworks, integrating an external blog typically involves making an AJAX request to the external blog's API and rendering the content. Due to the similar nature of these frameworks in handling HTTP requests, the approach is somewhat uniform:

  1. Use the native fetch API or a library like axios to request the blog content.
  2. Set up a route in your application (using React Router, Vue Router, etc.) for /blog.
  3. In the component mounted to the /blog route, make the request to the external blog and render the response.

Example in React (applicable concept for Vue, Angular, Svelte with respective syntax adjustments):

// BlogComponent.jsx in React
import React, { useEffect, useState } from 'react';

function BlogComponent() {
  const [blogContent, setBlogContent] = useState('');

  useEffect(() => {
    fetch('https://external-blog.com/api/posts')
      .then(response => response.json())
      .then(data => setBlogContent(data.content));
  }, []);

  return (
    <div dangerouslySetInnerHTML={{ __html: blogContent }} />
  );
}
Enter fullscreen mode Exit fullscreen mode

For each framework, adapt the fetching and state management according to its conventions. The key is to fetch the blog data from the external source and integrate it seamlessly into your app's component structure, making the external content appear as though it's a native part of your application.

Integrating Blog using Feed or Its Url

Integrating a blog into your website doesn't always mean you have to host the blog yourself. Sometimes, you might find it easier or more convenient to pull in content from an external blog. Two popular methods for doing this are using RSS feeds and iframes. Both offer unique advantages and considerations, especially when it comes to implementation and SEO.

RSS and iframe

Using RSS Feeds

RSS stands for Really Simple Syndication. It's a type of web feed that allows users and applications to access updates to online content in a standardized, computer-readable format. By using the RSS feed of an external blog, you can display its latest posts directly on your website.

To do this, you'd typically fetch the RSS feed programmatically and then parse the XML to render the blog posts in your site's HTML. This method keeps your site content fresh and ensures visitors have access to the latest posts without needing to navigate away from your site.

Here's a simplified example in JavaScript:

fetch('https://external-blog.com/rss')
  .then(response => response.text())
  .then(str => new window.DOMParser().parseFromString(str, "text/xml"))
  .then(data => {
    const items = data.querySelectorAll("item");
    let html = "";
    items.forEach(el => {
      html += `<article>
                <h2>${el.querySelector("title").textContent}</h2>
                <p>${el.querySelector("description").textContent}</p>
              </article>`;
    });
    document.getElementById("blog-posts").innerHTML = html;
  });
Enter fullscreen mode Exit fullscreen mode

Using Iframes

An iframe, or inline frame, is an HTML element that allows an external webpage to be embedded within your own webpage. This means you can simply place the external blog directly on your website by using its URL. However, while iframes are easy to implement, they have limitations, especially regarding SEO. Content within an iframe is considered part of the external site, not your site, so it doesn't contribute to your site's SEO.

Here's how you might embed an external blog using an iframe:

<iframe src="https://external-blog.com" width="100%" height="600px"></iframe>
Enter fullscreen mode Exit fullscreen mode

Note that, while iframes are convenient for embedding content like videos or external blogs, they're not ideal for SEO. Search engines typically crawl and index the content of the parent page, not the content within the iframe. This means that even though your site visitors can see and interact with the blog content through the iframe, this content doesn't directly boost your site's search engine ranking.

Tips for Seamless Blog Integration into Your Website

Integrating a blog into your main website isn't just about plugging in content; it's about creating a seamless experience for your visitors. This means ensuring that your blog feels like an integral part of your site, not just an afterthought. Here are some tips to help you achieve this.

Seamless Blog Integration

Consistent Look and Feel

Your blog and website should look like they belong together. This goes beyond just slapping your website's header on top of your blog posts. You'll want to match the font styles, color schemes, and even the button designs between your blog and the main site. If your website uses a minimalist design with lots of white space, your blog should follow suit. Consistency in design makes your whole site feel professional and cohesive.

Smooth Navigation and Linking

Navigation between your blog and the main site should be effortless. Ideally, visitors shouldn't even have to think about whether they're on your blog or another part of your site. Here are a couple of ways to achieve this:

  • Use Relative URLs: When linking to different parts of your site, use relative URLs (like /contact) rather than absolute paths (like www.yoursite.com/contact). This ensures that links will work correctly regardless of the subdomain or domain changes and helps keep the user experience smooth and consistent.

  • Unified Navigation Bar: Ensure that your site’s navigation bar is present across all pages, including blog posts. This makes it easy for visitors to explore other sections of your site without having to backtrack.

Engaging User Experience

Finally, consider the overall user experience. Your blog should load quickly, be easy to read, and be accessible on both desktop and mobile devices. Engaging images, videos, and other multimedia elements can also help to break up text and make your content more enjoyable to consume.

Common Pitfalls and How to Avoid Them

Integrating an external blog into your main website can be a game-changer for content diversity and engagement. However, there are common pitfalls that can hinder your success and impact your site's SEO negatively.

Web developer navigating SEO challenges in blog integration, highlighting the importance of overcoming common pitfalls for optimal website performance

Let's explore how to navigate these challenges and ensure your blog enhances your website's overall search engine ranking.

Avoid Duplicate Content

One of the biggest risks when integrating an external blog is creating duplicate content. Search engines penalize sites that publish content that exists elsewhere on the web. To avoid this, ensure that your integrated blog content is unique to your site or use canonical tags to indicate the preferred URL of content that's published in multiple places.

Maintain Loading Speed

Another critical factor is your website's loading speed. Integrating content from external sources can slow down your site, which negatively affects user experience and SEO. Optimize images, cache blog content, and use lazy loading to keep your site speedy.

Ensure Mobile Responsiveness

With the majority of users accessing the web through mobile devices, your integrated blog must be mobile-friendly. A responsive design ensures that your blog looks great and functions well on all devices, which is crucial for keeping visitors engaged and improving your SEO.

Keep Navigation Seamless

The integration should be seamless, with blog posts easily accessible from your main site. Avoid using absolute URLs that can create a disjointed experience. Instead, use relative paths that keep users within your domain, strengthening your site's internal linking and SEO.

Regularly Update Content

Fresh, regularly updated content is key to driving traffic and improving SEO. Ensure that your blog integration allows for easy updates and additions. This keeps your site dynamic and interesting for return visitors and search engines alike.

Conclusion

Integrating an external blog onto your website’s /blog URL can significantly enrich your site's content and enhance its SEO. By thoughtfully choosing how to host and display your blog, you can ensure that it serves as a dynamic extension of your main site, attracting more visitors and improving your search engine rankings.

I've explored several methods for integrating a blog for my Jekyll Blogging Editor and CMS, from RSS feeds and iframes to web server proxies and direct source code adjustments. Each approach has its unique advantages and considerations, especially regarding SEO. The key is to experiment with these methods to discover which one aligns best with your website's goals and your audience's needs.

I encourage you to try these techniques and see how they impact your site. And I'd love to hear from you! If you've experimented with integrating an external blog, or if you've faced any challenges along the way, reach out to me on social media, especially Twitter (X). Sharing your experiences can help others in the community make informed decisions and navigate their integration journeys more smoothly.


X (formerly Twitter) Follow

Top comments (0)