Skip to content

Commit

Permalink
Use osext on GitHub
Browse files Browse the repository at this point in the history
Fixes gohugoio#922

add finalize command and tests to change draft status of specified content to false and set date to Now()

undraft command

Allow hyphens in shortcode name

Fixes gohugoio#929

Keep trailing slash when baseUrl contains a sub path

Before this commit, .Site.BaseUrl ended up as:

http://mysite.com/ => http://mysite.com/
http://mysite.com/sub/ => http://mysite.com/sub

Now it becomes:

http://mysite.com/ => http://mysite.com/
http://mysite.com/sub/ => http://mysite.com/sub/

Fixed gohugoio#931

Improve error message on missing shortcode inner content

Fixes gohugoio#933

Allow the same shortcode to  be used with or without inline content

Fixes gohugoio#934

Update Readme.md with additional contribution guides

Added Gitter badge

Restructure top of Readme.md

Fixing image in readme

Using a smaller Header Image

Tidying the Readme a bit more

Update github-pages-blog.md

change `hugo serve` to `hugo server`

Add benchmark for the shortcode lexer

Apply gofmt -s

Avoid panic when pagination on 0 pages

Fixes gohugoio#948

Prevent 404.html from prettifying into 404/index.html

Restore @realchaseadams's commit 348e123
"Force `UglyUrls` option to force `404.html` file name"
which got lost after some refactoring (commit 8db3c0b).

Remove the equivalent "force `UglyUrls`" code for `sitemap.xml`
because the refactored code now calls `renderAndWriteXML()`
which uses `WriteDestFile()` which does not prettify a filename.

Fixes gohugoio#939

Fix errors reported by Go Vet

Fix some Go Lint errors

Apply some more Golint suggestions

helpers: apply some Golint rules

author: fix doc

hugolib: apply some Hugolint rules

page: make receiver name on Page methods consistent

Apply some Golint rules on Page, esp. making the method receiver names consistent:

(page *Page) ==> (p *Page)

menu: make receiver name on Page methods consistent

Apply some Golint rules on Menu, esp. making the method receiver names consistent.

hugolib: apply some more Golint rules

source: apply some Golint rules

livereload: apply some Golint rules

parser: apply some Golint rules

There is only one s.PageTarget() - so we cannot change it, even tempoararily. We have to find another solution to this.
...

Prevent 404.html from prettifying into 404/index.html

Restore @realchaseadams's commit 348e123
"Force `UglyUrls` option to force `404.html` file name"
which got lost after some refactoring (commit 8db3c0b).

Remove the equivalent "force `UglyUrls`" code for `sitemap.xml`
because the refactored code now calls `renderAndWriteXML()`
which uses `WriteDestFile()` which does not prettify a filename.

Fixes gohugoio#939 (reverted from commit c4c19ad)

Handle 404 thread safely

Replaces hack that temporarily changes a global flag.

Fixes gohugoio#955
Fixes gohugoio#939

Fix UglyUrls on Windows

Fixes gohugoio#958

Fix eq and ne tpl function issue

`eq` and `ne` template functions don't work as expected when those are
used with a raw number and a calculated value by add, sub etc. It's
caused by both numbers type differences. For example, `eq 5 (add 2 3)`
returns `false` because raw 5 is `int` while `add 2 3` returns 5 with
`int64`

This normalizes `int`, `uint` and `float` type values to `int64`,
`uint64` and `float64` before comparing them. Other type of value is
passed to comparing function without any changes.

Fix gohugoio#961

Add test cases for Ne and Eq type normalisation

See gohugoio#961

Add new min_version field to theme.toml template

Switch from fsnotify.v0 to fsnotify.v1 API (watcher)

Fixes gohugoio#357
See also gohugoio#761

Do not parse backup files with trailing '~' as templates

Fixes gohugoio#964

absurlreplacer: write replacements directly to the byte buffer

The extra step isn't needed and this makes the code simpler.

And slightly faster:

benchmark              old ns/op     new ns/op     delta
BenchmarkAbsUrl        19987         17498         -12.45%
BenchmarkXmlAbsUrl     10606         9503          -10.40%

benchmark              old allocs     new allocs     delta
BenchmarkAbsUrl        28             24             -14.29%
BenchmarkXmlAbsUrl     14             12             -14.29%

benchmark              old bytes     new bytes     delta
BenchmarkAbsUrl        3512          3297          -6.12%
BenchmarkXmlAbsUrl     2059          1963          -4.66%

parser: add some frontmatter test cases

Skip directories like node_modules from the watchlist

A local `node_modules` directory can easily contain
tens of thousands of files, easily exhausting the tiny
default max open files limit especially on OS X Yosemite,
in spite of the fact that  Hugo already had code in place
since February 2014 to try to raise the maxfiles ulimit.

Also skip `.git` and `bower_components` directories.

The file watching situation will improve when
https://github.com/go-fsnotify/fsevents become ready,
but until then, we will be thrifty.  :-)

Thanks to @chibicode for the suggestion.

See gohugoio#168 for continued discussions.

Add some basic tests for doArithmetic

We might have to take precision into account for floating point nubers ... at some point.

doArithmetic: add test for division by zero

Correct initialisms as suggested by golint

First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing gohugoio#959.

Remove trailing space from site build statistics

Update press coverage: Fix URL; new tutorial in Chinese

[Docs] Update and expand http://gohugo.io/overview/usage/

The `hugo help` output as shown in http://gohugo.io/overview/usage/
was not yet updated for v0.13. Thanks to @alebaffa for the heads up!

Also:
 - Clarify that, after using `hugo server`, the bare `hugo` command
   need to be run before deployment.
 - Add a section on running `hugo` as production web server,
   and add links to two blog posts of two Hugo users sharing
   their experience.

Partially fixes: gohugoio#852 and gohugoio#937

Add deprecated logger

Add double checking in Deprecated

To prevent possible duplicate log statements.

source: add some test cases for File

Do not ERROR-log missing /data dir

Fixes gohugoio#930

Experimental AsciiDoc support with external helpers

See gohugoio#470

 * Based on existing support for reStructuredText files

 * Handles content files with extensions `.asciidoc` and `.ad`

 * Pipes content through `asciidoctor --safe -`.
   If `asciidoctor` is not installed, then `asciidoc --safe -`.

 * To make sure `asciidoctor` or `asciidoc` is found, after adding
   a piece of AsciiDoc content, run `hugo` with the `-v` flag
   and look for this message:

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

Caveats:

 * The final "Last updated" timestamp is currently not stripped.

 * When `hugo` is run with `-v`, you may see a lot of these messages

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

   if you have lots of `*.ad`, `*.adoc` or `*.asciidoc` files.

 * Some versions of `asciidoc` may have trouble with its safe mode.
   To test if you are affected, try this:

        $ echo "Hello" | asciidoc --safe -
        asciidoc: ERROR: unsafe: ifeval invalid
        asciidoc: FAILED: ifeval invalid safe document

   If so, I recommend that you install `asciidoctor` instead.

Feedback and patches welcome!

Ideally, we should be using https://github.com/VonC/asciidocgo,
@VonC's wonderful Go implementation of Asciidoctor.  However,
there is still a bit of work needed for asciidocgo to expose
its API so that Hugo can actually use it.

Until then, hope this "experimental AsciiDoc support through external
helpers" can serve as a stopgap solution for our community. :-)

2015-01-30: Updated for the replaceShortcodeTokens() syntax change
2015-02-21: Add `.adoc` extension as suggested by @Fale

Conflicts:
	helpers/content.go

Add Seq template func

Very similar to GNU's seq.

Fixes gohugoio#552

Conflicts:
	tpl/template.go

Added image support to the sitemap.xml template

Conflicts:
	tpl/template_embedded.go

Revert "Added image support to the sitemap.xml template"

This reverts commit 3c147bd.

Fixes gohugoio#972

removed duplicate word in readme

delete finalize files
  • Loading branch information
bep authored and mohae committed Mar 15, 2015
1 parent bb13d82 commit 84b62ac
Show file tree
Hide file tree
Showing 68 changed files with 1,644 additions and 869 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Hugo
![Hugo](https://raw.githubusercontent.com/spf13/hugo/master/docs/static/img/hugo-logo.png)

A Fast and Flexible Static Site Generator built with love by [spf13](http://spf13.com/) and [friends](https://github.com/spf13/hugo/graphs/contributors) in [Go][].

[![Build Status](https://travis-ci.org/spf13/hugo.png)](https://travis-ci.org/spf13/hugo) [![wercker status](https://app.wercker.com/status/1a0de7d703ce3b80527f00f675e1eb32 "wercker status")](https://app.wercker.com/project/bykey/1a0de7d703ce3b80527f00f675e1eb32) [![Build status](https://ci.appveyor.com/api/projects/status/n2mo912b8s2505e8/branch/master?svg=true)](https://ci.appveyor.com/project/spf13/hugo/branch/master)
[Website](http://gohugo.io) |
[Forum](https://discuss.gohugo.io) |
[Chat](https://gitter.im/spf13/hugo) |
[Documentation](http://gohugo.io/overview/introduction/) |
[Installation Guide](http://gohugo.io/overview/installing/) |
[Twitter](http://twitter.com/spf13)

[![Build Status](https://travis-ci.org/spf13/hugo.png)](https://travis-ci.org/spf13/hugo) [![wercker status](https://app.wercker.com/status/1a0de7d703ce3b80527f00f675e1eb32 "wercker status")](https://app.wercker.com/project/bykey/1a0de7d703ce3b80527f00f675e1eb32) [![Build status](https://ci.appveyor.com/api/projects/status/n2mo912b8s2505e8/branch/master?svg=true)](https://ci.appveyor.com/project/spf13/hugo/branch/master) [![Join the chat at https://gitter.im/spf13/hugo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/hugo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Overview

Expand Down Expand Up @@ -74,7 +82,16 @@ To update Hugo’s dependencies, use `go get` with the `-u` option.

go get -u -v github.com/spf13/hugo

## Contributing Code
## Contributing to Hugo

We welcome contributions to Hugo of any kind including documentation, themes, organization, tutorials, blog posts, bug reports, issues, feature requests, feature implementation, pull requests, answering questions on the forum, helping to manage issues, etc. The Hugo community and maintainers are very active and helpful and the project benefits greatly from this activity.

[![Throughput Graph](https://graphs.waffle.io/spf13/hugo/throughput.svg)](https://waffle.io/spf13/hugo/metrics)

If you have any questions about how to contribute or what to contribute please ask on the [forum](http://discuss.gohugo.io)


## Code Contribution Guide

Contributors should build Hugo and test their changes before submitting a code change.

Expand Down
3 changes: 3 additions & 0 deletions bufferpool/bufpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ var bufferPool = &sync.Pool{
},
}

// GetBuffer returns a buffer from the pool.
func GetBuffer() (buf *bytes.Buffer) {
return bufferPool.Get().(*bytes.Buffer)
}

// PutBuffer returns a buffer to the pool.
// The buffer is reset before it is put back into circulation.
func PutBuffer(buf *bytes.Buffer) {
buf.Reset()
bufferPool.Put(buf)
Expand Down
14 changes: 7 additions & 7 deletions commands/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/spf13/viper"
)

var OutputDir string
var Unsafe bool
var outputDir string
var unsafe bool

var convertCmd = &cobra.Command{
Use: "convert",
Expand Down Expand Up @@ -80,8 +80,8 @@ func init() {
convertCmd.AddCommand(toJSONCmd)
convertCmd.AddCommand(toTOMLCmd)
convertCmd.AddCommand(toYAMLCmd)
convertCmd.PersistentFlags().StringVarP(&OutputDir, "output", "o", "", "filesystem path to write files to")
convertCmd.PersistentFlags().BoolVar(&Unsafe, "unsafe", false, "enable less safe operations, please backup first")
convertCmd.PersistentFlags().StringVarP(&outputDir, "output", "o", "", "filesystem path to write files to")
convertCmd.PersistentFlags().BoolVar(&unsafe, "unsafe", false, "enable less safe operations, please backup first")
}

func convertContents(mark rune) (err error) {
Expand Down Expand Up @@ -134,10 +134,10 @@ func convertContents(mark rune) (err error) {
page.SetSourceContent(psr.Content())
page.SetSourceMetaData(metadata, mark)

if OutputDir != "" {
page.SaveSourceAs(filepath.Join(OutputDir, page.FullFilePath()))
if outputDir != "" {
page.SaveSourceAs(filepath.Join(outputDir, page.FullFilePath()))
} else {
if Unsafe {
if unsafe {
page.SaveSource()
} else {
jww.FEEDBACK.Println("Unsafe operation not allowed, use --unsafe or set a different output path")
Expand Down
77 changes: 45 additions & 32 deletions commands/hugo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
// Copyright © 2013-2015 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,6 +36,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/nitro"
"github.com/spf13/viper"
"gopkg.in/fsnotify.v1"
)

//HugoCmd is Hugo's root command. Every other command attached to HugoCmd is a child command to it.
Expand All @@ -55,8 +56,8 @@ Complete documentation is available at http://gohugo.io`,
var hugoCmdV *cobra.Command

//Flags that are to be added to commands.
var BuildWatch, IgnoreCache, Draft, Future, UglyUrls, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, NoTimes bool
var Source, CacheDir, Destination, Theme, BaseUrl, CfgFile, LogFile, Editor string
var BuildWatch, IgnoreCache, Draft, Future, UglyURLs, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, NoTimes bool
var Source, CacheDir, Destination, Theme, BaseURL, CfgFile, LogFile, Editor string

//Execute adds all child commands to the root command HugoCmd and sets flags appropriately.
func Execute() {
Expand All @@ -74,6 +75,7 @@ func AddCommands() {
HugoCmd.AddCommand(convertCmd)
HugoCmd.AddCommand(newCmd)
HugoCmd.AddCommand(listCmd)
HugoCmd.AddCommand(undraftCmd)
}

//Initializes flags
Expand All @@ -88,8 +90,8 @@ func init() {
HugoCmd.PersistentFlags().StringVarP(&Destination, "destination", "d", "", "filesystem path to write files to")
HugoCmd.PersistentFlags().StringVarP(&Theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
HugoCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
HugoCmd.PersistentFlags().BoolVar(&UglyUrls, "uglyUrls", false, "if true, use /filename.html instead of /filename/")
HugoCmd.PersistentFlags().StringVarP(&BaseUrl, "baseUrl", "b", "", "hostname (and path) to the root eg. http://spf13.com/")
HugoCmd.PersistentFlags().BoolVar(&UglyURLs, "uglyUrls", false, "if true, use /filename.html instead of /filename/")
HugoCmd.PersistentFlags().StringVarP(&BaseURL, "baseUrl", "b", "", "hostname (and path) to the root eg. http://spf13.com/")
HugoCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is path/config.yaml|json|toml)")
HugoCmd.PersistentFlags().StringVar(&Editor, "editor", "", "edit new content with this editor, if provided")
HugoCmd.PersistentFlags().BoolVar(&Logging, "log", false, "Enable Logging")
Expand Down Expand Up @@ -126,10 +128,10 @@ func InitializeConfig() {
viper.SetDefault("DefaultLayout", "post")
viper.SetDefault("BuildDrafts", false)
viper.SetDefault("BuildFuture", false)
viper.SetDefault("UglyUrls", false)
viper.SetDefault("UglyURLs", false)
viper.SetDefault("Verbose", false)
viper.SetDefault("IgnoreCache", false)
viper.SetDefault("CanonifyUrls", false)
viper.SetDefault("CanonifyURLs", false)
viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"})
viper.SetDefault("Permalinks", make(hugolib.PermalinkOverrides, 0))
viper.SetDefault("Sitemap", hugolib.Sitemap{Priority: -1})
Expand All @@ -154,7 +156,7 @@ func InitializeConfig() {
}

if hugoCmdV.PersistentFlags().Lookup("uglyUrls").Changed {
viper.Set("UglyUrls", UglyUrls)
viper.Set("UglyURLs", UglyURLs)
}

if hugoCmdV.PersistentFlags().Lookup("disableRSS").Changed {
Expand All @@ -180,14 +182,14 @@ func InitializeConfig() {
if hugoCmdV.PersistentFlags().Lookup("logFile").Changed {
viper.Set("LogFile", LogFile)
}
if BaseUrl != "" {
if !strings.HasSuffix(BaseUrl, "/") {
BaseUrl = BaseUrl + "/"
if BaseURL != "" {
if !strings.HasSuffix(BaseURL, "/") {
BaseURL = BaseURL + "/"
}
viper.Set("BaseUrl", BaseUrl)
viper.Set("BaseURL", BaseURL)
}

if viper.GetString("BaseUrl") == "" {
if viper.GetString("BaseURL") == "" {
jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
}

Expand Down Expand Up @@ -291,10 +293,17 @@ func copyStatic() error {
return syncer.Sync(publishDir, staticDir)
}

// getDirList provides NewWatcher() with a list of directories to watch for changes.
func getDirList() []string {
var a []string
dataDir := helpers.AbsPathify(viper.GetString("DataDir"))
walker := func(path string, fi os.FileInfo, err error) error {
if err != nil {
if path == dataDir && os.IsNotExist(err) {
jww.WARN.Println("Skip DataDir:", err)
return nil

}
jww.ERROR.Println("Walker: ", err)
return nil
}
Expand All @@ -317,12 +326,16 @@ func getDirList() []string {
}

if fi.IsDir() {
if fi.Name() == ".git" ||
fi.Name() == "node_modules" || fi.Name() == "bower_components" {
return filepath.SkipDir
}
a = append(a, path)
}
return nil
}

filepath.Walk(helpers.AbsPathify(viper.GetString("DataDir")), walker)
filepath.Walk(dataDir, walker)
filepath.Walk(helpers.AbsPathify(viper.GetString("ContentDir")), walker)
filepath.Walk(helpers.AbsPathify(viper.GetString("LayoutDir")), walker)
filepath.Walk(helpers.AbsPathify(viper.GetString("StaticDir")), walker)
Expand All @@ -349,7 +362,7 @@ func buildSite(watching ...bool) (err error) {
return nil
}

//NewWatcher creates a new watcher to watch filesystem events.
// NewWatcher creates a new watcher to watch filesystem events.
func NewWatcher(port int) error {
if runtime.GOOS == "darwin" {
tweakLimit()
Expand All @@ -369,59 +382,59 @@ func NewWatcher(port int) error {

for _, d := range getDirList() {
if d != "" {
_ = watcher.Watch(d)
_ = watcher.Add(d)
}
}

go func() {
for {
select {
case evs := <-watcher.Event:
case evs := <-watcher.Events:
jww.INFO.Println("File System Event:", evs)

static_changed := false
dynamic_changed := false
static_files_changed := make(map[string]bool)
staticChanged := false
dynamicChanged := false
staticFilesChanged := make(map[string]bool)

for _, ev := range evs {
ext := filepath.Ext(ev.Name)
istemp := strings.HasSuffix(ext, "~") || (ext == ".swp") || (ext == ".swx") || (ext == ".tmp") || (strings.HasPrefix(ext, ".goutputstream"))
istemp := strings.HasSuffix(ext, "~") || (ext == ".swp") || (ext == ".swx") || (ext == ".tmp") || strings.HasPrefix(ext, ".goutputstream")
if istemp {
continue
}
// renames are always followed with Create/Modify
if ev.IsRename() {
if ev.Op&fsnotify.Rename == fsnotify.Rename {
continue
}

isstatic := strings.HasPrefix(ev.Name, helpers.GetStaticDirPath()) || strings.HasPrefix(ev.Name, helpers.GetThemesDirPath())
static_changed = static_changed || isstatic
dynamic_changed = dynamic_changed || !isstatic
staticChanged = staticChanged || isstatic
dynamicChanged = dynamicChanged || !isstatic

if isstatic {
if staticPath, err := helpers.MakeStaticPathRelative(ev.Name); err == nil {
static_files_changed[staticPath] = true
staticFilesChanged[staticPath] = true
}
}

// add new directory to watch list
if s, err := os.Stat(ev.Name); err == nil && s.Mode().IsDir() {
if ev.IsCreate() {
watcher.Watch(ev.Name)
if ev.Op&fsnotify.Create == fsnotify.Create {
watcher.Add(ev.Name)
}
}
}

if static_changed {
if staticChanged {
jww.FEEDBACK.Println("Static file changed, syncing\n")
utils.StopOnErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("PublishDir"))))

if !BuildWatch && !viper.GetBool("DisableLiveReload") {
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized

// force refresh when more than one file
if len(static_files_changed) == 1 {
for path := range static_files_changed {
if len(staticFilesChanged) == 1 {
for path := range staticFilesChanged {
livereload.RefreshPath(path)
}

Expand All @@ -431,7 +444,7 @@ func NewWatcher(port int) error {
}
}

if dynamic_changed {
if dynamicChanged {
fmt.Print("\nChange detected, rebuilding site\n")
const layout = "2006-01-02 15:04 -0700"
fmt.Println(time.Now().Format(layout))
Expand All @@ -442,7 +455,7 @@ func NewWatcher(port int) error {
livereload.ForceRefresh()
}
}
case err := <-watcher.Error:
case err := <-watcher.Errors:
if err != nil {
fmt.Println("error:", err)
}
Expand Down
8 changes: 6 additions & 2 deletions commands/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,17 @@ func touchFile(x ...string) {

func createThemeMD(inpath string) (err error) {

by := []byte(`name = "` + strings.Title(helpers.MakeTitle(filepath.Base(inpath))) + `"
by := []byte(`# theme.toml template for a Hugo theme
# See https://github.com/spf13/hugoThemes#themetoml for an example
name = "` + strings.Title(helpers.MakeTitle(filepath.Base(inpath))) + `"
license = "MIT"
licenselink = "https://github.com/.../.../LICENSE.md"
licenselink = "https://github.com/yourname/yourtheme/blob/master/LICENSE.md"
description = ""
homepage = "http://siteforthistheme.com/"
tags = ["", ""]
features = ["", ""]
min_version = 0.13
[author]
name = ""
Expand Down
12 changes: 6 additions & 6 deletions commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ func server(cmd *cobra.Command, args []string) {

viper.Set("port", serverPort)

BaseUrl, err := fixUrl(BaseUrl)
BaseURL, err := fixURL(BaseURL)
if err != nil {
jww.ERROR.Fatal(err)
}
viper.Set("BaseUrl", BaseUrl)
viper.Set("BaseURL", BaseURL)

if err := memStats(); err != nil {
jww.ERROR.Println("memstats error:", err)
Expand All @@ -114,9 +114,9 @@ func serve(port int) {
httpFs := &afero.HttpFs{SourceFs: hugofs.DestinationFS}
fileserver := http.FileServer(httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir"))))

u, err := url.Parse(viper.GetString("BaseUrl"))
u, err := url.Parse(viper.GetString("BaseURL"))
if err != nil {
jww.ERROR.Fatalf("Invalid BaseUrl: %s", err)
jww.ERROR.Fatalf("Invalid BaseURL: %s", err)
}
if u.Path == "" || u.Path == "/" {
http.Handle("/", fileserver)
Expand All @@ -137,10 +137,10 @@ func serve(port int) {

// fixUrl massages the BaseUrl into a form needed for serving
// all pages correctly.
func fixUrl(s string) (string, error) {
func fixURL(s string) (string, error) {
useLocalhost := false
if s == "" {
s = viper.GetString("BaseUrl")
s = viper.GetString("BaseURL")
useLocalhost = true
}
if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") {
Expand Down
Loading

0 comments on commit 84b62ac

Please sign in to comment.