summaryrefslogtreecommitdiffstats
path: root/hugolib/site_test.go
Commit message (Collapse)AuthorAge
...
* Add configurable ref/relref error handling and notFoundURLBjørn Erik Pedersen2018-07-19
| | | | | | | | | Two new settings: * refLinksErrorLevel: ERROR (default) or WARNING. ERROR will fail the build. * refLinksNotFoundURL: Used as a placeholder when page references cannot be found. Fixes #4964
* Simplify .Site.GetPage etc.Bjørn Erik Pedersen2018-07-18
| | | | | | | | | | | | | | | | | | | | | | This commit is a follow up to a recent overhaul of the GetPage/ref/relref implemenation. The most important change in this commit is the update to `.Site.GetPage`: * To reduce the amount of breakage in the wild to its minimum, I have reworked .Site.GetPage with some rules: * We cannot support more than 2 arguments, i.e. .Site.GetPage "page" "posts" "mypage.md" will now throw an error. I think this is the most uncommon syntax and should be OK. It is an easy fix to change the above to .Site.GetPage "/posts/mypage.md" or similar. * .Site.GetPage "home", .Site.GetPage "home" "" and .Site.GetPage "home" "/" will give you the home page. This means that if you have page in root with the name home.md you need to do .Site.GetPage "/home.md" or similar This commit also fixes some multilingual issues, most notable it is now possible to do cross-language ref/relref lookups by prepending the language code to the path, e.g. `/jp/posts/mypage.md`. This commit also reverts the site building tests related to this to "Hugo 0.44 state", to get better control of the changes made. Closes #4147 Closes #4727 Closes #4728 Closes #4728 Closes #4726 Closes #4652
* Unify page lookupsVas Sudanagunta2018-07-18
| | | | | | | | | | | | | This commit unifies the core internal page index for all page kinds. This enables the `ref` and `relref` shortcodes to support all pages kinds, and adds a new page-relative `.GetPage` method with simplified signature. See #4147 See #4727 See #4728 See #4728 See #4726 See #4652
* hugolib: Remove empty resources/ dir after TestNewSiteDefaultLangAnthony Fok2018-07-10
|
* Add a way to merge pages by languageBjørn Erik Pedersen2018-03-16
| | | | | | | | | | | | As an example: ```html {{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }} ``` Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English. Fixes #4463
* hugolib: Remove unused codeBjørn Erik Pedersen2018-01-25
|
* Remove and update deprecation statusBjørn Erik Pedersen2018-01-25
|
* resource: Add front matter metadata to ResourceBjørn Erik Pedersen2018-01-17
| | | | | | | | | | | | This commit expands the Resource interface with 3 new methods: * Name * Title * Params All of these can be set in the Page front matter. `Name` will get its default value from the base filename, and is the value used in the ByPrefix and GetByPrefix lookup methods. Fixes #4244
* :sparkles: Implement Page bundling and image handlingBjørn Erik Pedersen2017-12-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is not the smallest in Hugo's history. Some hightlights include: * Page bundles (for complete articles, keeping images and content together etc.). * Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`. * Processed images are cached inside `resources/_gen/images` (default) in your project. * Symbolic links (both files and dirs) are now allowed anywhere inside /content * A new table based build summary * The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below). A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory: ```bash ▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render" benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64% ``` Fixes #3651 Closes #3158 Fixes #1014 Closes #2021 Fixes #1240 Updates #3757
* Make sure Date and PublishDate is always set to a value if one is availableBjørn Erik Pedersen2017-10-13
| | | | Fixes #3854
* Remove sourceRelativeLinksBjørn Erik Pedersen2017-08-02
| | | | Fixes #3766
* Switch from fork bep/inflect to markbates/inflectJorin Vogel2017-08-01
| | | | | Original package has received updates the fork hasn't. Without fork updates are easier to maintain.
* hugolib: Support reflinks starting with a slashBjørn Erik Pedersen2017-07-21
| | | | Fixes #3703
* all: Update import paths to gohugoio/hugoBjørn Erik Pedersen2017-06-13
|
* hugolib: Enable nested sectionsBjørn Erik Pedersen2017-06-08
| | | | Fixes #465
* hugolib: Fix ref/relref issue with duplicate base filenamesBjørn Erik Pedersen2017-05-26
| | | | | | This commit also makes that function 80x faster. Fixes #2507
* hugolib: Support regular pages in .Site.GetPageBjørn Erik Pedersen2017-05-26
| | | | Fixes #2844
* hugolib: Add BenchmarkGetPageBjørn Erik Pedersen2017-05-23
|
* hugolib: Avoid index.md in /index/index.htmlBjørn Erik Pedersen2017-04-27
| | | | | | | | | | | | | | Hugo 0.20 broke some sites that grouped their blog post and images together in subfolders. This commit re-introduces that behaviour: * If the file base name resolves to the same as the base name for the output type (i.e. "index" for HTML), the user probably meant it, so we treat that as an `uglyURL`, i.e. `my-blog-post-1.md`=> `/my-blog-post-1/index.html` * The main use case for this is to group blog post and images together. * Note that for the top level folder there will be a potential name conflict with a `section` `index.html` (if enabled) * This issue will not be relevant for subfolders in sections * Hugo will soon add support for nested sections, but we will have to find a way to separate them from the rest (`/content/_mysubsection` maybe). Fixes #3396
* hugolib: Fix handling of zero-length filesBjørn Erik Pedersen2017-04-23
| | | | | | This was a regression in Hugo 0.20. This commit makes sure that zeron-length files are not rendered to file. Fixes #3355
* hugolib: Add .Site.Params.mainSectionsBjørn Erik Pedersen2017-04-07
| | | | Fixes #3206
* hugolib: Add optional outputFormat to Ref/RelRefBjørn Erik Pedersen2017-04-04
| | | | Fixes #3224
* tpl: Rework to handle both text and HTML templatesBjørn Erik Pedersen2017-04-02
| | | | | | | | | | | | | | | | | Before this commit, Hugo used `html/template` for all Go templates. While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc. This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use. A couple of notes: * The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work. * Ambiguous types will fall back to HTML. * Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials. * Shortcode templates are, by definition, currently HTML templates only. Fixes #3221
* Revert "tpl: Rework to handle both text and HTML templates"Bjørn Erik Pedersen2017-04-02
| | | | | | | | Will have to take another stab at this ... This reverts commit 5c5efa03d2512749950b0d05a7d4bde35ecbdc37. Closes #3260
* tpl: Rework to handle both text and HTML templatesBjørn Erik Pedersen2017-04-02
| | | | | | | | | | | | | | | | | Before this commit, Hugo used `html/template` for all Go templates. While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc. This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use. A couple of notes: * The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work. * Ambiguous types will fall back to HTML. * Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials. * Shortcode templates are, by definition, currently HTML templates only. Fixes #3221
* Remove the now superflous defaultExtensionBjørn Erik Pedersen2017-03-27
| | | | And some other unsed fields and methods.
* hugolib: Refactor/-work the permalink/target path logicBjørn Erik Pedersen2017-03-27
| | | | | | | | | | | | | | | | | | | | This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done. This commit's goal is to say: * Every file target path is created by `createTargetPath`, i.e. one function for all. * That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on. * The path creation logic has full test coverage. * All permalinks, paginator URLs etc. are then built on top of that same logic. Fixes #1252 Fixes #2110 Closes #2374 Fixes #1885 Fixes #3102 Fixes #3179 Fixes #1641 Fixes #1989
* hugolib: Correctly identify "my_index_page.md"Bjørn Erik Pedersen2017-03-25
| | | | | | The above example was earlier identified as a section page and not a regular page. Fixes #3234
* hugolib: Fix .Site.LastChangeBjørn Erik Pedersen2017-02-19
| | | | | | | | | | This commit makes sure that the `.Site.LastChange` is fetched from the latest page modification date. Previously, this value was fetched from the last page in the default page sort, which may not be the last by date if weight is set. Fixes #2909 Closes #2910
* hugolib: More test helper cleanupBjørn Erik Pedersen2017-02-18
|
* hugolib: Test helper cleanupBjørn Erik Pedersen2017-02-17
|
* all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen2017-02-17
| | | | | | | | 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
* Use OS fs by defaultBjørn Erik Pedersen2017-02-15
| | | | Fixes #3032
* hugolib: Fix error for non-renderable HTML content with shortcodesBjørn Erik Pedersen2017-02-10
| | | | | | | This commit re-introduces template lookup order that was accidently removed as part of the template nonglobal refactoring. Fixes #3021
* all: Refactor to nonglobal file systemsBjørn Erik Pedersen2017-02-04
| | | | | Updates #2701 Fixes #2951
* all: Refactor to nonglobal template handlingBjørn Erik Pedersen2017-01-10
| | | | Updates #2701
* all: Refactor to non-global loggerBjørn Erik Pedersen2017-01-07
| | | | | | | Note that this looks like overkill for just the logger, and that is correct, but this will make sense once we start with the template handling etc. Updates #2701
* node to page: Remove NodeBjørn Erik Pedersen2016-11-22
| | | | | | And misc. TODO-fixes Updates #2297
* node to page: Make Nodes into PagesBjørn Erik Pedersen2016-11-22
| | | | | | | * `.Site.Pages` now contains all page types, including sections etc. * `.Data.Pages` will also contain "node type" pages where relevant. Updates #2297
* node to page: Handle aliases, 404, robots.txt, sitemapBjørn Erik Pedersen2016-11-22
| | | | Updates #2297
* node to page: Basic outlineBjørn Erik Pedersen2016-11-22
| | | | Updates #2297
* Fix RSS Title regressionBjørn Erik Pedersen2016-10-28
| | | | | | And add tests to make sure it doesn't happen again. Fixes #2645
* Add missing template error loggingBjørn Erik Pedersen2016-10-25
|
* Remove now superfluous lowercasingBjørn Erik Pedersen2016-10-24
| | | | | See #2615 See #1129
* all: Unify case of config variable namesAlbert Nigmatzianov2016-10-24
| | | | | | | | | 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.
* Fix case issue Viper vs Blackfriday configBjørn Erik Pedersen2016-10-16
| | | | | | There are still work to be done in the case department, but that will have to be another day. Fixes #2581 See https://github.com/spf13/viper/issues/261
* Lazy calculate WordCount, ReadingTime and FuzzyWordCountBjørn Erik Pedersen2016-09-14
| | | | | | | | | | | | | | | | | | | | | This avoids having to execute these expensive operations for sites not using these values. This commit sums up a set of wordcounting and autosummary related performance improvements. The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise: ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 21293005843 20032857342 -5.92% benchmark old allocs new allocs delta BenchmarkHugo-4 65290922 65186032 -0.16% benchmark old bytes new bytes delta BenchmarkHugo-4 9771213416 9681866464 -0.91% ``` Closes #2378
* Render main content language in root by defaultBjørn Erik Pedersen2016-09-06
| | | | Fixes #2312
* Multilingual TODO-fixes, take 1Bjørn Erik Pedersen2016-09-06
| | | | See #2309
* Improve language handling in URLsBjørn Erik Pedersen2016-09-06
| | | | | | | The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func. This commit also adds two new template funcs: relLangURL and absLangURL. See #2309