Display /posts in root domain /

Hi guys.

I am done with migration of my WordPress blog to Hugo. It is awesome. I already switched to new blog but immediately I noticed a difference in display structure of content.

In WordPress my content is displayed in the root domain : https://www.mydomain.com/postname. I am using mainroad theme which is awesome but the content is displayed https://www.mydomain.com/posts/postname.

I tried to modify the theme config by adding following changes but it didn’t work:

post = “/:slug”
mainSections = ["/"]

Here is my config.toml
baseurl = “/”
title = “mydomain.com
languageCode = “en-us”
paginate = “10” # Number of posts per page
theme = “mainroad”
disqusShortname = “” # Enable comments by entering your Disqus shortname
googleAnalytics = “UA-XXXXXX” # Enable Google Analytics by entering your tracking id

[Author] # Used in authorbox
  name = "ffff"
  bio = "ffff"

  avatar = "img/avatar.png"

post = "/:slug"

  mainSections = ["/"]

  #subtitle = "Just another site" # Subtitle of your site. Used in site header
  #description = "John Doe's Personal blog about everything" # Site description. Used in meta description
  #copyright = "John Doe" # copyright holder, otherwise will use site title
  opengraph = true # Enable OpenGraph if true
  twitter_cards = true # Enable Twitter Cards if true
  readmore = false # Show "Read more" button in list if true
  authorbox = true # Show authorbox at bottom of pages if true
  toc = false # Enable Table of Contents
  post_navigation = true # Show post navigation at bottom of pages if true
  post_meta = ["date", "categories", "translations"] # Order of post meta information
  #mainSections = ["post", "blog", "news"] # specify section pages to show on home page and the "Recent articles" widget
  #dateformat = "2006-01-02" # change the format of dates
  #mathjax = true # Enable MathJax
  #mathjaxPath = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js" # Specify MathJax path
  #mathjaxConfig = "TeX-AMS-MML_HTMLorMML" # Specify MathJax config
  #highlightColor = "#e22d30" # Override highlight color
  customCSS = ["css/custom.css"] # Include custom CSS files
  customJS = ["js/custom.js"] # Include custom JS files

  home = "right" # Configure layout for home page
  list = "left"  # Configure layout for list pages
  single = false # Configure layout for single pages
  # Enable widgets in given order
  widgets = ["ads", "social", "recent", "categories", "languages"]

  recent_num = 10 # Set the number of articles in the "Recent articles" widget
  tags_counter = true # Enable counter for each tag in "Tags" widget (disabled by default)

  # Enable parts of social widget
  facebook = ""
  twitter = ""
  #instagram = "username"
  linkedin = ""
  #telegram = "username"
  github = ""
  gitlab = ""
  #bitbucket = "username"
  #email = "example@example.com"

disable = true
anonymizeIP = true
disable = false
respectDoNotTrack = true
useSessionStorage = false
disable = false
simple = false
disable = false
enableDNT = true
simple = false
disable = false
simple = false
disable = false
privacyEnhanced = true

How can I display my posts in root domain instead of domain/posts/content ?


If your content is in /content/posts/, then the permalink configuration has to match:

posts = “/:slug”

This also needs to match the actual section names, ie posts etc.


Thanks a lot. It worked like a charm.