digitalcraftsman / hugo-material-docs

Port of Martin Donath's mkdocs-material theme to Hugo
MIT License
706 stars 186 forks source link

theme does not work for 'offline' (local file system) sites #61

Open andrew-g-za opened 7 years ago

andrew-g-za commented 7 years ago

Hi there,

I love the theme, but I'm struggling to get it to generate successfully for offline sites (i.e., served from the local file system, not a web server). I took the example site provided, removed the baseurl property and tried every combination of relativeURLs = true / false and uglyurls = true / false - all to no avail.

Is there anything special i need to do to make this theme work offline?

ArtFlag commented 7 years ago

FYI, it works for me out of the box. Are you sure you followed the setup instructions?

andrew-g-za commented 7 years ago

Hi, Yes, i'm pretty sure i did it correctly, but i might have gotten something wrong. Here's what i did (im on Windows 10, Hugo 0.2):

$ C:\temp $ mkdir materialdocs $ cd materialdocs $ git clone https://github.com/digitalcraftsman/hugo-material-docs.git themes/hugo-material-docs $ xcopy /E themes\hugo-material-docs\exampleSite*.* $hugo version

Hugo Static Site Generator v0.20 windows/amd64 BuildDate: 2017-04-10T15:16:39+02:00

Now, if i run $ hugo server

And go to http://localhost:1313/ the site renders correctly. If i look at the Adding content menu item on the left, its link is to http://localhost:1313/adding-content/ which works when i navigate there.

Now lets try offline:

$ hugo

If i simply run open the /public/index.html page i get this:

image

Clearly not right. But the default config has a base url property. Lets remove it and add the relativeurls property, since its meant to be used for offline viewing according to the hugo docs:

By default, all relative URLs are left unchanged by Hugo, which can be problematic when you want to make your site browsable from a local file system.

So in config.toml, i comment out the baseurl property and add the relativeurl:

#baseurl = "https://example.org/"
relativeURLs = true

Trying again: $ hugo

Now the site renders correctly:

image

But the link to the Adding content item is

file:///C:/Temp/materialdocs/public/adding-content/

Navigating to that produces this (im using firefox, your browser may show something different, but the outcome is the same, you wont see the page):

image

This is what i meant by the theme does not work for offline sites - some links don't include a file name (index.html or whatever) so will only work online behind a server that maps requests from / to /index.html