The display of Hugo's page is not showing up properly

I'm currently in the process of building a static blog with Hugo utilizing these resources (here and here).

After setting up Hugo and creating a basic placeholder blog post for initial testing, I noticed that the page displays correctly when I run hugo server -D and navigate to localhost:1313 in a browser. However, the same page does not render correctly when directly accessed by opening public/index.html in a browser.

The configuration file being used is from the theme included with my chosen design. Within this config file, I've customized elements like the theme name, baseURL set to '/', as well as smaller details such as authorship information, descriptions, and copyright.

Why is it that index.html renders properly when served through the local Hugo server but malfunctions when accessed as a standalone file via a web browser?

Here you can see my blog rendering correctly through the Hugo server

Here is an example of my blog post rendered incorrectly through direct access of the index.html file

This snippet showcases my current configuration setup:

CopyPasteYourConfigFileHere

Furthermore, here is the raw code for the generated public/index.html:

YourGeneratedIndexHtmlCodeHere

Answer №1

If your layout files utilize the relURL function,¹ you should add the following code snippet to your config.toml.

relativeURLs = true

Ensure that...

  • this line appears above all TOML tables
  • the term relativeURLs maintains its exact upper- and lowercase characters

You can find more information about this feature at https://gohugo.io/content-management/urls/#relative-urls:

By default, Hugo leaves all relative URLs unchanged, which may cause issues when attempting to browse your site locally. Enabling relativeURLs in your site configuration will prompt Hugo to adjust all relative URLs to be relative to the current content. For instance, if your /posts/first/ page contains a link to /about/, Hugo will change the URL to ../../about/.

¹ More details about relURL can be found at https://gohugo.io/functions/relurl/, and it is used in your theme, likely https://github.com/alexandrevicenzi/soho.

Answer №2

Your webpage seems to be missing the CSS files, which may indicate that they are not properly linked in the HTML file. Make sure to check the theme or layouts for any references.

I noticed in your config.toml that the baseURL is set to /. It should actually include the full hostname like https://yoursite.com/. For more information, refer to Hugo's config documentation here.

If you are running locally with hugo server, you can override this setting using the --baseURL flag.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Rails and HAML to incorporate looping HTML5 video tags

I have a question regarding how I'm using Rails video_tag to display a video: = video_tag("SMR_video.mp4", :controls => false, :autobuffer => true, :autoplay => true, :loop => true, :id => "hero-video") After implementing the above co ...

Full height container with footer

Currently facing an issue with a page I am working on. Here is a snippet of the code: <div id="header"> // header.. </div> <div id="content"> // content where ajax is loaded (should cover at least 100% of the site height) <!- ...

Using jQuery to Toggle Visibility of Table Rows

I'm facing a challenge in creating a basic table layout where all the table rows are initially hidden when the document loads. The goal is to display specific rows when a corresponding button is clicked, but my current implementation doesn't seem ...

Styling the footer of a webpage using CSS to adapt to different browser

I am currently working on a webpage that includes a footer. The footer is positioned correctly, but I encounter an issue when resizing the browser from bottom to top. For further details, please refer to the image below: Below is the CSS code for my foote ...

Position the div element below the navigation bar

I am attempting to embed a Leaflet map within a standard Sails.js view. Sails.js automatically includes a page header on every page. Currently, with a fixed height, the map appears like this: #mapid { height: 400px; } https://i.sstatic.net/pzOdql.jpg ...

linking ng-style through live html

I am encountering an issue with dynamic data stored in the database. When trying to apply a style to a div element retrieved from the server response, I am facing difficulties with implementing it using ng-style. If the data is static, everything works fi ...

How to dynamically adjust font size using Javascript

Is there a way to adjust the font size of the left-column using JavaScript? <div id="left-column"> <a href="">1</a><br> <a href="">2</a><br> <a href="">3</a><br> <a href=""> ...

Updating the border color of a floating form using React Bootstrap

Is there a way to customize the color of the border to something other than blue in React Bootstrap? https://i.sstatic.net/ScIw1.jpg ...

Split-screen homepage design (CSS)

I am trying to design the homepage for my site using only html/css add-ons and without altering any other rule. So far, I have managed to create the blocks themselves but I'm stuck on how to position images behind the buttons, center everything verti ...

Is there a light font that cannot be replicated?

I attempted to replicate the font style used in this website's menu, but after implementing it into my WordPress CSS theme, the text still appears bold. Is there a particular technique I can use to achieve the lighter version of the font? I have loade ...

In Firefox, the focus outline is not shown on a div that has a mask-image CSS rule applied to

In my code, I have multiple div elements that have the mask-image and -webkit-mask-image CSS rules applied to them. These divs are being used as UI slider components, so I want keyboard users to be able to tab between them and use the arrow keys to adjust ...

Ways to retrieve attribute value in Selenium python without the use of .get_attribute() method

I am new to posting questions, so please let me know if I need to provide more clarification. I am also a beginner in Python, so I hope that I am using the right terms to phrase my question. Essentially, I have developed a customizable web scraper that re ...

tips on displaying information in a vertical tab orientation

I'm struggling to figure out how to loop inside the <TabPanel> in order to render data using React vertical tabs. I've provided the code I've tried and the data coming from an API. Check out the codesandbox at https://codesandbox.io/s/ ...

How to show PHP/HTML code within the PHP script and display it in HTML

Struggling to incorporate the following code into a PHP block for reuse on other webpages due to numerous errors. Any guidance on how to make this work? Here's the code block within a PHP file: <select name="products"> ...

What is the functionality of the <center> tag in HTML5 scripts, even though it has been deprecated?

HTML5 brings about changes, such as the elimination of the center tag. To put this to the test, I ran the following script: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Page Title</title> < ...

Choose the tag and class then retrieve the custom attribute

I'm currently attempting to retrieve a specialized attribute utilizing jquery and subsequently choose it, nevertheless I am encountering some difficulties with the process Below is the jquery code I have implemented to access the value var stockId = ...

Creating obstacles in a canvas can add an extra layer of challenges and

I am working on creating a basic platformer game using the code displayed below. window.onload = function(){ var canvas = document.getElementById('game'); var ctx = canvas.getContext("2d"); var rightKeyPress = false; var leftKeyPress = false; ...

Issue with Jquery causing tabs to malfunction

Check out the CodePen I'm currently working on where I have included the following Jquery code to create a tab-style interface where each button displays specific content. Here's the Jquery code I'm using: $('.content-canvas').fi ...

jQuery unable to populate a div with content using the .load method

My goal is to use a jQuery script to grab the content from the "content" class on another page and insert it into the "code" div. Here's the code I'm working with: <script type="text/javascript"> $(document).ready(function() { $(&a ...

Excessive CSS Padding on Tablets and Mobile Devices

I recently completed this website based on a PSD design, using basic CSS techniques. However, I am encountering an issue with unwanted padding on the sides of the site when viewed on mobile devices and tablets. I would like the left and right edges of the ...