Real estate website with Hugo

Hello,
I’m using wordpress right now for my real estate website and I’m thinking about moving to static website.
Is it possible to create a real estate website that has search functionality and importing or syncing data (property listing) from CSV to the site, so every time I update the CSV the listing on the website will be updated?
If it is possible can someone show me what I should learn in order to create the site that I want?
I only know some programming languages like HTML, CSS and a little bit of PHP because I’m using wordpress right now, and I’m more to the site owner rather than a website developer because I only building it for myself.
So any explanations, hint, or guide would be very much appreciated because I’m really interested in learning building static website.

Thank you!

1 Like

Search functionality is available, but I haven’t implemented it myself (yet) so will let others comment on that aspect.

However, I have created a Google Sheet with data. You can publish this to the web as a csv (within Google sheets), which can then be pulled into Hugo and iterated over.

See https://gohugo.io/templates/data-templates/

You will of course need to build Hugo after you alter the spreadsheet, and then publish, but there are several automated deployment tools available (Netifly, Wercker etc). But yes, I do believe you can do what you are looking for with some coding.

You can use CSV files to insert data into a page, but you can’t generate a new page for each entry in the CSV. If you want to do that, you’d need a separate script to generate Hugo contents file for each record in the CSV.

1 Like

Yes, but what you can do it set a key value in the spreadsheet and match it with the page .params.

So yes, you would have to create a new page for each entry, but you can automatically bring in the correct row from the spreadsheet and display it via the template. For example (set column 1 of the spreadsheet (index 0) to an address like “8thestreet”, and set the front matter of the post with address: 8thestreet:

                    {{ range $i, $r := getCSV .Site.Params.sep .Site.Params.spreadsheetname }}
                        {{ if eq (index $r 0) $.Params.address }}
                 
                            <li>{{ index $r 9 }}</li>

                        {{end}}
                    {{end}}

I suppose you can then as mooreason says, create a script to generate all the files. I suppose you could even replace the param with the file name, and use that as the key in the spreadsheet.

2 Likes

Or you could use bash to generate the .md files from your CSV file outside Hugo with a bit of regex and the csplit command in Linux/Unix and then move the files into your Hugo content directory to generate the site.

See here for a tutorial: https://lou.pe/blog/converting-csv-tables-to-markdown-files

Haven’t tried it myself yet, but I plan to try.

EDIT
It works very well.

3 Likes

Wow! I thought I will be ignored just like on other forums.
Feel welcomed here :smile:
Thank you all for the response, really appreciate it!

I think there is a lot of things that I have to learn especially about the converting CSV to markdown files.

Anyway does Algolia search works well with Hugo? because for what that I know it works well with Jekyll.
Or is there any other options besides Algolia?
I need a search function that can be used for e-commerce and real estate website.

Pretty sure the docs site is using Algolia so someone should know something about it. Maybe search in here - it might be mentioned.

1 Like

Actually, I have searched for it in here and I think Algolia can be used on Hugo, however, I just want to know how much compatible is Algolia with Hugo, and if there are other search functions that work better with Hugo while providing same or better functionality.