How do I figure out what page a user previously was on before landing on a specific page?
As an example, when a user visits products/product-a/ and clicks on preview, they come to the products/preview page. I’d like to display a link to the products/product-a/ page on products/preview. If they were previously on products/product-b/, I’d like to show that link.
Thanks. I’m not familiar with javascript so that’s why I was wondering if it was possible. I need to think a bit more about what I’m trying to achieve as I’m overcomplicating things. Thanks again.
I want to figure out the previous page a user was on in order to display information related to that page on the current page they are viewing.
Example:
User visits products/product-a/
User clicks on the preview link
User lands on products/preview/
On products/preview/ the previous page’s – products/product-a/ – title and description along with other information from the markdown file, product-a.md, is displayed.
I thought by using document.referrer; I would be apply to capture the url of the previous page, pass it to a go variable, and then do the logic using Hugo. But that’s apparently not possible.
My understanding of breadcrumbs is that they follow the structure of the content folder. Using my example:
When a user visits products/products-a/, the breadcrumbs become:
home > products > products-a
When a user visits preview from products/product-a/, the breadcrumbs become:
if the breadcrumb is home > products > preview you don’ know he was on products-a before so it’s not a referrer thing but a simple hierarchical thing of the current page. because preview.md is (if you did it all the way it works best) inside of /content/products/.
You want a preview of something. What is the preview? A gallery? Add a gallery to product-a.md that pop ups per click. A file sample (PDF?)? add it as page ressource to product a.
Page ressources:
/content/products/product-a/index.md - product info (the index.html page)
/content/products/product-a/sample.pdf - a page resource you can use in index.html
An important thing to note is, hugo is building before your users view the site, so, it’s not involved. Nor does it inject any javascript automatically. It helps you assemble the site, taking exactly what you give it and building the site quickly.