summaryrefslogtreecommitdiffstats
path: root/hugolib/page_permalink_test.go
AgeCommit message (Collapse)Author
2023-05-16Create a struct with all of Hugo's config optionsBjørn Erik Pedersen
Primary motivation is documentation, but it will also hopefully simplify the code. Also, * Lower case the default output format names; this is in line with the custom ones (map keys) and how it's treated all the places. This avoids doing `stringds.EqualFold` everywhere. Closes #10896 Closes #10620
2022-12-19modules: Make the module.workspace=off as default (note)Bjørn Erik Pedersen
Also, resolve any workspace file relative to the workingDir. Fixes #10553
2020-12-03all: Format code with gofumptBjørn Erik Pedersen
See https://github.com/mvdan/gofumpt
2019-08-12tests: Convert from testify to quicktestBjørn Erik Pedersen
2019-07-24Add Hugo ModulesBjørn Erik Pedersen
This commit implements Hugo Modules. This is a broad subject, but some keywords include: * A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project. * A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects. * Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running. * Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions. * A new set of CLI commands are provided to manage all of this: `hugo mod init`, `hugo mod get`, `hugo mod graph`, `hugo mod tidy`, and `hugo mod vendor`. All of the above is backed by Go Modules. Fixes #5973 Fixes #5996 Fixes #6010 Fixes #5911 Fixes #5940 Fixes #6074 Fixes #6082 Fixes #6092
2019-04-07hugolib: Log warning on relative front matter url with langBjørn Erik Pedersen
Will do this for one version only, as there may be situations where this is the correct thing. Also add some more related test cases. Fixes #5818
2019-04-02hugolib: Allow relative URLs in front matterBjørn Erik Pedersen
Before this commit you would have to do this in multilingual setups: ``` --- title: "Custom!" url: "/jp/custom/foo" --- ``` This commit allows for relative URLs, e.g: ``` --- title: "Custom!" url: "custom/foo" --- ``` Which is obviously easier and more portable. The meaning of relative may change to include more in the future (e.g. role based access). Fixes #5704
2019-03-23Make Page an interfaceBjørn Erik Pedersen
The main motivation of this commit is to add a `page.Page` interface to replace the very file-oriented `hugolib.Page` struct. This is all a preparation step for issue #5074, "pages from other data sources". But this also fixes a set of annoying limitations, especially related to custom output formats, and shortcodes. Most notable changes: * The inner content of shortcodes using the `{{%` as the outer-most delimiter will now be sent to the content renderer, e.g. Blackfriday. This means that any markdown will partake in the global ToC and footnote context etc. * The Custom Output formats are now "fully virtualized". This removes many of the current limitations. * The taxonomy list type now has a reference to the `Page` object. This improves the taxonomy template `.Title` situation and make common template constructs much simpler. See #5074 Fixes #5763 Fixes #5758 Fixes #5090 Fixes #5204 Fixes #4695 Fixes #5607 Fixes #5707 Fixes #5719 Fixes #3113 Fixes #5706 Fixes #5767 Fixes #5723 Fixes #5769 Fixes #5770 Fixes #5771 Fixes #5759 Fixes #5776 Fixes #5777 Fixes #5778
2018-12-21hugolib: Improve logic of output path trimmingCameron Moore
Fixes #4666
2017-06-13all: Update import paths to gohugoio/hugoBjørn Erik Pedersen
2017-03-27Remove the now superflous defaultExtensionBjørn Erik Pedersen
And some other unsed fields and methods.
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-02-04all: Refactor to nonglobal file systemsBjørn Erik Pedersen
Updates #2701 Fixes #2951
2016-11-22node to page: Fix the Page copy()Bjørn Erik Pedersen
By embeding the init sync.Once var in a pointer so we can reset it when we copy the page. Updates #2297
2016-11-22node to page: Handle URLsBjørn Erik Pedersen
This includes removing the error return value from Permalink and RelPermalink. We ignore that error all over the place, so we might as well remove it. Updates #2297
2016-11-22node to page: Remove NodeBjørn Erik Pedersen
And misc. TODO-fixes Updates #2297
2016-11-22node to page: Rename PageType to KindBjørn Erik Pedersen
And embed that on Page. Updates #2297
2016-11-22node to page: Add Pages to PageBjørn Erik Pedersen
As an alias to .Data.Pages for home page etc. Also renamte NodeType to PageType and make it a string so it can be used in `where`. Updates #2297
2016-10-24all: Unify case of config variable namesAlbert Nigmatzianov
All config variables starts with low-case and uses camelCase. If there is abbreviation at the beginning of the name, the whole abbreviation will be written in low-case. If there is abbreviation at the end of the name, the whole abbreviation will be written in upper-case. For example, rssURI.
2016-10-24Avoid reading from Viper for path and URL funcsBjørn Erik Pedersen
The gain, given the "real sites benchmark" below, is obvious: ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 14497594101 13084156335 -9.75% benchmark old allocs new allocs delta BenchmarkHugo-4 57404335 48282002 -15.89% benchmark old bytes new bytes delta BenchmarkHugo-4 9933505624 9721984424 -2.13% ``` Fixes #2495
2016-09-06Make it possible to configure Blackfroday per languageBjørn Erik Pedersen
See #2309
2016-09-06Optimize the multilanguage build processBjørn Erik Pedersen
Work In Progress! This commit makes a rework of the build and rebuild process to better suit a multi-site setup. This also includes a complete overhaul of the site tests. Previous these were a messy mix that were testing just small parts of the build chain, some of it testing code-paths not even used in "real life". Now all tests that depends on a built site follows the same and real production code path. See #2309 Closes #2211 Closes #477 Closes #1744
2015-12-10Add copyright header to that source files that don’t have one.Anthony Fok
See #1646
2015-05-28Support `Fish and Chips` sectionbep
Section names are also used as the title of the list pages, but naming section folders as `Fish and Chips` and similar didn't work very well. This commit fixes that. This commit also changes the title casing of the section titles. Some may argue that this is a breaking change, but the old behaviour was also pretty broken, even for languages that use title capitalizations, as it didn't follow any particular style guide, `fish and chips` became `Fish And Chips` etc. Now it just turns the first letter into upper case, so `Fish and Chips` will be left as `Fish and Chips`. People wanting the good old behaviour can use the `title` template func. Fixes #1176
2015-05-28Add some missing page permalink test casesbep
2015-05-27Never remove trailing slash in RelPermalinkbep
Fixed #1174
2015-05-20Stop Viper from leaking across many of the tests (now tests pass regardless ↵spf13
of order tested)
2015-03-18More initialism corrections (golint)Anthony Fok
Thanks to @bep's new, brilliant helpers.Deprecated() function, the following functions or variables are transitioned to their new names, preserving backward compatibility for v0.14 and warning the user of upcoming obsolescence in v0.15: * .Url → .URL (for node, menu and paginator) * .Site.BaseUrl → .Site.BaseURL * .Site.Indexes → .Site.Taxonomies * .Site.Recent → .Site.Pages * getJson → getJSON * getCsv → getCSV * safeHtml → safeHTML * safeCss → safeCSS * safeUrl → safeURL Also fix related initialisms in strings and comments. Continued effort in fixing #959.
2015-03-11Correct initialisms as suggested by golintAnthony Fok
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 #959.
2015-01-23Fix RelPermalink() and Urls in menus vs canonifyUrlsbep
canonifyUrls=true, RelPermalink and baseUrl with sub-path did not work. This fixes that by adding a check for canonifyUrl=trues=true in RelPermalink(). So given - baseUrl "http://somehost.com/sub/" - the path "some-path/file.html" For canonifyUrls=false RelPermalink() returns "/sub/some-path/file.html" For canonifyUrls=true RelPermalink() returns "/some-path/file.html" In the last case, the Url will be made absolute and clickable in a later step. This commit also makes the menu urls defined in site config releative. To make them work with canonifying of urls, the context root is prepended if canonifying is turned off. Fixes #519 Fixes #711
2014-12-09Fix various Windows-issuesbep
File handling was broken on Windows. This commit contains a revision of the path handling with separation of file paths and urls where needed. There may be remaining issues and there may be better ways to do this, but it is easier to start that refactoring job with a set of passing tests. Fixes #687 Fixes #660
2014-10-16Big refactor of how source files are used. Also added default destination ↵spf13
extension option.
2014-08-25Fix #302. Links now have trailing slashes.spf13
2014-08-25Support subdir in baseurl.Nate Finch
Mainly this was a change to helpers.MakePermalink, but to get the local server to run correctly, we needed to redirect the path of the request from /foo to /. In addition, I added tests for the server's code for fixing up the base url with different config file & CLI options.
2014-05-28SiteInfo is now a pointer on the Nodespf13
2014-04-07Fixing all tests to pass with new Viper Configspf13
2014-02-28Make per-page url overrides take precedence over section permalink settingsAsk Bjørn Hansen
This seems more reasonable to me. I didn't understand why the pUrl comparision was on len > 2; I changed it to 0. Closes #212.
2014-02-27Reorganization of helpers. Centralized Url/Path logic. Fixed #175.spf13
2014-02-02Fix permalink bug in uglyurls mode (refs #187).Anton Ageev
2013-11-20fixed trailing dir slash when using slugTim Esselens
See testcase, dir + slug contained double slash when dir had a trailing slash. Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-10-08Permalink to include multiple directories levelsNoah Campbell
2013-10-08Test case for permalink functionalityNoah Campbell
2013-10-08Refactor layout selection codeNoah Campbell
The render code path would use a fallback if there was an exception. This change instead relies on explicit declaration of the layout to use and includes a check to see if the layout indeed exists before attempting to render it.